Out of the box, Pandoc already does a useful job of translating .bike
files directly to formatted MS Word .docx
files.
If we start with a Bike file like:
then, with pandoc
installed (e.g. with brew install pandoc
) the command line:
pandoc -f html -t docx note.bike -o note.docx
creates an MS Word file like:
In which only the highlight
formatting ( underlying <marked>
tagging) has not been translated automatically.
I haven’t, so far, experimented with customizing pandoc outputs, but it does appear to be possible. The .docx
XML markup that we would need to generate, for example, has this kind of pattern:
<w:r w:rsidRPr="00F12617">
<w:rPr>
<w:highlight w:val="yellow"/>
</w:rPr>
<w:t>marked</w:t>
</w:r>
More generally, pandoc translates bike files to an intermediate (JSON-formatted abstract syntax tree) format which can be represented (and post-processed) in JavaScript or Lua etc. For example,
pandoc -f html -t json note.bike -o note.json
Gives us the JSON representation below which:
- preserves the
<mark>
tagging for the highlight format, and - should allow for transforms like designating the top N levels of an outline as heading levels, etc
Expand disclosure triangle to view Pandoc JSON AST source
{
"pandoc-api-version": [
1,
22,
2
],
"meta": {},
"blocks": [
{
"t": "BulletList",
"c": [
[
{
"t": "Div",
"c": [
[
"P9",
[],
[]
],
[
{
"t": "Para",
"c": [
{
"t": "Str",
"c": "Various"
},
{
"t": "Space"
},
{
"t": "Str",
"c": "inline"
},
{
"t": "Space"
},
{
"t": "Str",
"c": "formats"
}
]
},
{
"t": "BulletList",
"c": [
[
{
"t": "Div",
"c": [
[
"vi",
[],
[]
],
[
{
"t": "Para",
"c": [
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Str",
"c": "alpha"
},
{
"t": "Space"
}
]
]
},
{
"t": "SoftBreak"
},
{
"t": "Strong",
"c": [
{
"t": "Str",
"c": "bold"
}
]
},
{
"t": "SoftBreak"
},
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Space"
},
{
"t": "Str",
"c": "etc"
}
]
]
}
]
}
]
]
}
],
[
{
"t": "Div",
"c": [
[
"Ru",
[],
[]
],
[
{
"t": "Para",
"c": [
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Str",
"c": "beta"
},
{
"t": "Space"
}
]
]
},
{
"t": "SoftBreak"
},
{
"t": "Emph",
"c": [
{
"t": "Str",
"c": "italic"
}
]
},
{
"t": "SoftBreak"
},
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Space"
},
{
"t": "Str",
"c": "etc"
}
]
]
}
]
}
]
]
}
],
[
{
"t": "Div",
"c": [
[
"il",
[],
[]
],
[
{
"t": "Para",
"c": [
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Str",
"c": "gamma"
},
{
"t": "Space"
}
]
]
},
{
"t": "SoftBreak"
},
{
"t": "Code",
"c": [
[
"",
[],
[]
],
"code"
]
},
{
"t": "SoftBreak"
},
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Space"
},
{
"t": "Str",
"c": "etc"
}
]
]
}
]
}
]
]
}
],
[
{
"t": "Div",
"c": [
[
"uA",
[],
[]
],
[
{
"t": "Para",
"c": [
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Str",
"c": "delta"
},
{
"t": "Space"
}
]
]
},
{
"t": "SoftBreak"
},
{
"t": "Strikeout",
"c": [
{
"t": "Str",
"c": "strike"
}
]
},
{
"t": "SoftBreak"
},
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Space"
},
{
"t": "Str",
"c": "etc"
}
]
]
}
]
}
]
]
}
],
[
{
"t": "Div",
"c": [
[
"V3",
[],
[]
],
[
{
"t": "Para",
"c": [
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Str",
"c": "epsilon"
},
{
"t": "Space"
}
]
]
},
{
"t": "SoftBreak"
},
{
"t": "Span",
"c": [
[
"",
[
"mark"
],
[]
],
[
{
"t": "Str",
"c": "marked"
}
]
]
},
{
"t": "SoftBreak"
},
{
"t": "Span",
"c": [
[
"",
[],
[]
],
[
{
"t": "Space"
},
{
"t": "Str",
"c": "etc"
}
]
]
}
]
}
]
]
}
],
[
{
"t": "Div",
"c": [
[
"du",
[],
[]
],
[
{
"t": "Para",
"c": [
{
"t": "Str",
"c": "zeta"
},
{
"t": "Space"
},
{
"t": "Str",
"c": "plain"
},
{
"t": "Space"
},
{
"t": "Str",
"c": "etc"
}
]
}
]
]
}
]
]
}
]
]
}
]
]
}
]
}