Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

markdown-notes-tree

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-notes-tree - npm Package Compare versions

Comparing version 1.12.0 to 1.13.0-beta.0

2

package.json
{
"name": "markdown-notes-tree",
"version": "1.12.0",
"version": "1.13.0-beta.0",
"description": "Generate Markdown trees that act as a table of contents for a folder structure with Markdown notes",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -80,2 +80,8 @@ Project status:

### `--allowMissingTitle`
Don't throw an error on missing title but instead use the file name as fallback.
Example: `markdown-notes-tree --allowMissingTitle`
### `--ignore`

@@ -127,2 +133,8 @@

### `--readmeFilename`
Filename to use for README files (both the main README file and subdirectory README files). The default is `README.md`.
Example: `markdown-notes-tree --readmeFilename Home.md`
### `--silent`

@@ -129,0 +141,0 @@

@@ -25,3 +25,3 @@ "use strict";

function shouldIgnoreFile(name, relativeParentPath, environment) {
if (!name.endsWith(".md") || name === "README.md") {
if (!name.endsWith(".md") || name === environment.options.readmeFilename) {
return true;

@@ -28,0 +28,0 @@ }

@@ -6,2 +6,3 @@ "use strict";

const defaultOptions = {
allowMissingTitle: false,
ignore: [],

@@ -14,2 +15,3 @@ includeAllDirectoriesByDefault: false,

orderNotesByTitle: false,
readmeFilename: "README.md",
silent: false,

@@ -16,0 +18,0 @@ subdirectoryDescriptionOnNewLine: false,

@@ -47,3 +47,3 @@ "use strict";

const relativePath = path.join(relativeParentPath, directory.name);
const relativeReadmePath = path.join(relativePath, "README.md");
const relativeReadmePath = path.join(relativePath, environment.options.readmeFilename);
const readmeContents = getCurrentContents(relativeReadmePath);

@@ -78,3 +78,7 @@ const title = getTitleParagraphFromMarkdownFile(readmeContents, relativeReadmePath);

isDirectory: false,
titleParagraph: getTitleParagraphFromMarkdownFileOrThrow(contents, relativePath),
titleParagraph: determineTreeTitleParagraphForMarkdownFile(
contents,
relativePath,
environment
),
filename: file.name

@@ -122,6 +126,6 @@ });

function getTitleParagraphFromMarkdownFileOrThrow(contents, relativePath) {
const title = getTitleParagraphFromMarkdownFile(contents, relativePath);
function determineTreeTitleParagraphForMarkdownFile(contents, relativePath, environment) {
const titleFromFile = getTitleParagraphFromMarkdownFile(contents, relativePath);
if (!title) {
if (!titleFromFile && !environment.options.allowMissingTitle) {
const absolutePath = pathUtils.getAbsolutePath(relativePath);

@@ -131,3 +135,4 @@ throw new Error(`No title found for Markdown file ${absolutePath}`);

return title;
const filenameWithoutExtension = path.parse(relativePath).name;
return titleFromFile || markdownParser.escapeText(filenameWithoutExtension);
}

@@ -87,3 +87,3 @@ "use strict";

if (treeNode.isDirectory && environment.options.linkToSubdirectoryReadme) {
linkTarget = linkTarget + "/README.md";
linkTarget = linkTarget + "/" + environment.options.readmeFilename;
}

@@ -90,0 +90,0 @@

@@ -13,3 +13,3 @@ "use strict";

function writeTreeToMainReadme(tree, environment) {
const mainReadmePath = pathUtils.getAbsolutePath("README.md");
const mainReadmePath = pathUtils.getAbsolutePath(environment.options.readmeFilename);
const currentContents = fs.readFileSync(mainReadmePath, { encoding: "utf-8" });

@@ -62,3 +62,3 @@ const markdownForTree = treeMarkdownGenerator.getMarkdownForTree(tree, environment);

function writeTreeToDirectoryReadme(pathParts, titleParagraph, treeForDirectory, environment) {
const filePathParts = [...pathParts, "README.md"];
const filePathParts = [...pathParts, environment.options.readmeFilename];
const relativeFilePath = path.join(...filePathParts);

@@ -65,0 +65,0 @@ const absoluteFilePath = pathUtils.getAbsolutePath(relativeFilePath);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc