Skip to content

Code block injection for markdown files.

License

Notifications You must be signed in to change notification settings

cedric-parisi/pulpMd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pulp Markdown

Code block injection for markdown files.

Set snippet tags

We use the common double-brace format for the snippet tags:

{{snippet <Snippet Name>}}

Optionally, you can add a file extension filter to the snippet tag to limit the code to (a) specific language(s). This will only insert from files named <Snippet Name>.{js,go,rs}:

{{snippet <Snippet Name> [js,go,rs]}}

Create snippets

Snippets are matched to the file name, with the code block tagged with the file extension.

So, if we have the snippet tag:

### Here's an example:
{{snippet SampleCode [js]}}

and code file SampleCode.js:

function SampleFunction() {
  console.log("Show in markdown");
}

The resulting markdown will be:

### Here's an example:
```js
function SampleFunction() {
  console.log("Show in markdown");
}
```

Usage

To inject in-place, simply run:

$ pulpMd --target=input.md

Specify an output file with:

$ pulpMd --target=input.md --output=output.md

Additional options:

--injectDir (-d): Root directory of snippets to inject
--norecur   (-r): No recursive searches in injectDir
--output    (-o): Output markdown file
--fileExt   (-e): Extension list.  Can be used to filter "js,go,java" or used to specify the markdown code identifier "aspx:asp".
--notags    (-n): Leave snippet tags in output.  [To facilitate multiple-pass processing]
--quotes    (-q): Leave block quotes in output when no code was inserted in the following tag.  [Default cleans up block-quote headings if there's no code to insert]

About

Code block injection for markdown files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%