kiwi0fruit / pandoctools

Profile manager of text processing pipelines: Pandoc filters, any text CLI filters. Atom+Markdown+Pandoc+Jupyter workflow, export to ipynb. Uses Stitch fork: https://github.com/kiwi0fruit/knitty
MIT License
52 stars 9 forks source link

Pug Pandoc filter #34

Closed kiwi0fruit closed 5 years ago

kiwi0fruit commented 5 years ago

The filter should works after knitty so that I could output Markdown via knitty and then pug it. Problem: how to skip eval in knitty but run later in pandoc-pug?

---
pandoc-pug:
  pug: True
  results: raw | ast  # raw is default
# knitty option:
eval:
  py: True
  pug: False
  other: True
eval: True
...
Some text with raw html icon: `i.icon.checkmark`{.pug}

Some text with pug inline code: `i.icon.checkmark`{.pug pug=False}

Some text with knitty error: `i.icon.checkmark`{.pug eval=True results=raw}

```pug
h1 header

pandoc-pug: pug: False eval: pug: False other: True

Some text with raw html icon: i.icon.checkmark{pug=True}

Some text with pug inline code: i.icon.checkmark{.pug}


https://github.com/kakulukia/pypugjs/blob/master/pypugjs/filters.py  
https://pugjs.org/language/filters.html  
Add filter "pandoc"
The filter should be able to recall previous pug Declarations. All pug code pieces should work as a single document. Does extension `inline_code_attributes` work 
by default?

* [x] ~make sure knitty puts latex, html to Raw blocks like {=html}~
* [x] ~Write about installing VSCode as there can be selected pug language which highlight is compatible with `HTML(pug(r""" ` - but add a space after `"""`. https://github.com/kakulukia/pypugjs~
* [ ] ~write pug Helper that works like if all pug chunks are part of the one single document.~

# ~Pandoc filter~

~Better option in my opinion.~  
~https://github.com/kakulukia/pypugjs~  
~Worth considering writing pug jupyter kernel/magic. Already exists:~ ~https://github.com/bollwyvl/jademagic I should check how knitty handles raw html and see what jyputer data return jade magic.~

~https://github.com/knowsuchagency/ninjadog~

# ~Pug filter~

* ~https://pugjs.org/language/filters.html~
* ~https://github.com/RelaxedJS/ReLaXed/wiki/Special-file-renderings~

~Two runs schema: first run of the pug file fills temp file as a stack of the Markdown pieces of text. Second run execs pandoctools on the stack with special separators and pulls from the modified stack.~

~If the filter doesn't get reloaded every time it's called from pug then it can easily know if it's called the first time.~
~When stack from the first run through is done it's converted to the stack of the second type. Conversion is done on the first call of the filter. When not first call of the filter then we pull from the stack of the second type (or fill stack of the first type if the second type is absent).~

~But what if the filter never ever realoaded? The first Markdown chunk should be specially marked.~
kiwi0fruit commented 5 years ago

pandoc-pug filter is nice but I would better go with pypugjs in knitty untill it becomes really unconvenient.