React with Native

Bringing together React and React Native

GitHub

README

Markdown parse js

markdown-parse-js (

OperationClassification

TODO: Ensure embedding this will embed the actual docs in my markdown renderer. I guess it might already do so!

TODO: It would be great to learn more about this topic and see if I can make more cross-environment packages. A great use case would be to create a wrapper around the current fs-orm to enable using it at the frontend too.

OperationClassification cjs)

js-only operation containing all kinds of functions that help parsing markdown

Api reference
mdToJsonParse()

makes a markdown parse from a markdown string

TODO: markdownStringToMarkdownParse is a better name. First make a refactor script for this, because it is too hard to rename stuff that is used a lot.

TODO: BUG: it doesn't take into account triple backticks! if there is markdown inside of the triple backticks, it can still be seen as main markdown. Triple backticks are stronger!

Input
markdownStringstring
Output
📄 mdToJsonParse (exported const)

makes a markdown parse from a markdown string

TODO: markdownStringToMarkdownParse is a better name. First make a refactor script for this, because it is too hard to rename stuff that is used a lot.

TODO: BUG: it doesn't take into account triple backticks! if there is markdown inside of the triple backticks, it can still be seen as main markdown. Triple backticks are stronger!

getImplicitId()

Implicit ids are a convention in markdown. A title gets an implicit id by removing spaces and making the title lowercase.

See https://stackoverflow.com/questions/6695439/how-to-link-to-a-named-anchor-in-multimarkdown

Input
titlestring
OutputString
markdownParseToMarkdownString()

NB: this just uses RAW!

Use markdownParseToMarkdownStringFromContent for the real deal

Input
markdownParseMarkdownParse
OutputString
parseFrontmatterMarkdownString()

splits a markdown string into its frontmatter object and the raw content (without frontmatter)

Input
markdownWithFrontmatterstring
Output
📄 getImplicitId (exported const)

Implicit ids are a convention in markdown. A title gets an implicit id by removing spaces and making the title lowercase.

See https://stackoverflow.com/questions/6695439/how-to-link-to-a-named-anchor-in-multimarkdown

📄 markdownParseToMarkdownString (exported const)

NB: this just uses RAW!

Use markdownParseToMarkdownStringFromContent for the real deal

📄 parseFrontmatterMarkdownString (exported const)

splits a markdown string into its frontmatter object and the raw content (without frontmatter)

getMarkdownIntro()

This function takes a markdown parse and gets the first paragraph and a title from it, if available.

Currently assumes that the first paragraph starts directly after the title or there is no title and the content is at the beginning.

TODO: It would be better to find the first paragraph based on the level.

Input
markdownParse{ }
Output{ title: { },
firstParagraph: { },
}
📄 getMarkdownIntro (exported const)

This function takes a markdown parse and gets the first paragraph and a title from it, if available.

Currently assumes that the first paragraph starts directly after the title or there is no title and the content is at the beginning.

TODO: It would be better to find the first paragraph based on the level.

getMarkdownReferencePaths()
Input
markdownStringstring
Outputstring[]
markdownParseToMarkdownStringFromContent()
Input
markdownParseMarkdownParse
Outputstring
📄 getMarkdownReferencePaths (exported const)
📄 markdownParseToMarkdownStringFromContent (exported const)
Internal
Show internal (21)
chunkToStringRecursively()
Input
chunkMarkdownChunk
OutputString
getChunkParagraphsRecursively()

Get all paragraphs (content values) recursively from a MarkdownChunk

Input
chunkMarkdownChunk
Outputstring[]
getMarkdownParseParagraphs()

Gets all paragraphs (recursively) from a MarkdownParse

Input
markdownParseMarkdownParse
Outputstring[]
getMarkdownReferencesFromParagraph()

Gets all markdown references from a paragraph

Input
paragraphstring
Output{ alt?: string,
path: string,
isAsset?: boolean,
}[]
mdContentParseRecursively()

recursively parses a string containing markdown (without frontmatter) into a MarkdownChunk[]

Improve:

  • include the comment-type (TODO/NB/etc), both on a chunk level and on root level
  • parse paragraphs further around the assets
Input
markdownStringstring
Output
parseMarkdownParagraph()

Parse markdown paragraph

Should split it up for every thing it encounters...

Input
paragraphstring
Output{ isNewline?: boolean,
codeblock?: { type?: string,
code?: string,
},
text?: string,
isBolded?: boolean,
isItalic?: boolean,
isBackticked?: boolean,
reference?: { alt?: string,
path: string,
isAsset?: boolean,
},
}[]
parseMdToChunks()

should get chunks recursively. first just look for every h1 line. everything after the h1 line is the children until there's another h1 line, then do this recursivley for h2, h3, etc.

Input
markdownStringstring
Output
removeHeaderPrefix()

removes header prefix (##### etc) and trims whats behind that

Input
stringstring
Output
🔹 MarkdownCodeblock

Properties:

NameTypeDescription
type (optional)string
code (optional)string
🔹 MarkdownParagraphChunk

Properties:

NameTypeDescription
isNewline (optional)boolean
codeblock (optional)object
text (optional)string
isBolded (optional)boolean
isItalic (optional)boolean
isBackticked (optional)boolean
reference (optional)object
🔹 MarkdownParseConfig

Properties:

NameTypeDescription
noFinal (optional)boolean
frontmatterSchema (optional)object
🔹 MarkdownReference

Properties:

NameTypeDescription
alt (optional)string
pathstring
isAsset (optional)boolean
📄 chunkToStringRecursively (exported const)
📄 exampleMarkdownFileContents (exported const)
📄 getChunkParagraphsRecursively (exported const)

Get all paragraphs (content values) recursively from a MarkdownChunk

📄 getMarkdownParseParagraphs (exported const)

Gets all paragraphs (recursively) from a MarkdownParse

📄 getMarkdownReferencesFromParagraph (exported const)

Gets all markdown references from a paragraph

📄 mdContentParseRecursively (exported const)

recursively parses a string containing markdown (without frontmatter) into a MarkdownChunk[]

Improve:

  • include the comment-type (TODO/NB/etc), both on a chunk level and on root level
  • parse paragraphs further around the assets
📄 parseMarkdownParagraph (exported const)

Parse markdown paragraph

Should split it up for every thing it encounters...

📄 parseMdToChunks (exported const)

should get chunks recursively. first just look for every h1 line. everything after the h1 line is the children until there's another h1 line, then do this recursivley for h2, h3, etc.

📄 removeHeaderPrefix (exported const)

removes header prefix (##### etc) and trims whats behind that