transmutes html and markdown to @magic view fragments
npm i -g @magic/transmute
// executable as magic-transmute now
magic-transmute
npm i --save @magic/transmute
magic-transmute --help
- markdown - convert markdown to magic functions
- html - convert html to magic functions
- file - convert file to magic functions
- --add-wrapper - add export default[] to the returned string. - alias: ["--addWrapper"]
- --no-pretty - do not run prettier. - alias: ["--noPretty"]
- --markdown - force markdown parser to run. - alias: ["--mark", "-m"]
- --output - output file path - alias: ["--out", "-o"]
- --input - input file path - alias: ["--in", "-i"]
- --help - this help text - alias: ["-help", "help", "--h", "-h"]
- --str - an input string of either html or markdown, depending on running command
magic-transmute html --str '<a href="https://magic.github.io">magic!</a>'
magic-transmute markdown --str '[magic!](https://magic.github.io)'
magic-transmute file --input input.html --output output.mjs
(.markdown and .md get recognized):
magic-transmute file --input input.md --output output.mjs
(arbitrary file extensions)
magic-transmute file --input input.txt --output output.mjs --markdown
import transmute from '@magic/transmute'
// html to magic
transmute.html('<a href="https://magic.github.io">magic!</a>')
// returns: `Link({ to: 'https://magic.github.io' }, 'magic!')`
// markdown to magic
transmute.markdown('[magic!](https://magic.github.io)')
// returns: `Link({ to: 'https://magic.github.io' }, 'magic!')`
const magic = transmute.markdown('[magic!](https://magic.github.io)')
console.log(magic)
// logs: `Link({ to: 'https://magic.github.io' }, 'magic!')`
// that's it.
first release
update dependencies
fix cli
update @magic dependencies to use npm packages instead of github
- extract state from html and markdown files
- allow usage of state variables in markdown and html
- pass options from LexLex to marked.Lexer
- only implant state in html if it has not been passed as argument
- correctly camelCase object keys for html tags
- correctly merge passed state with in-file state for markdown and html
remove commonjs support, node >= 13.5.0 required
export correct cli file
do not lowercase @magic-module names, some other minor changes
do not wrap @magic-modules in p tags
- remove eval from state injection function.
- correctly handle both ${} and {{}} variables in markdown and html files.
state keys in ${} and {{ }} get trimmed... doh.
return originalState, which is the state derived from the markdown/html file. this allows @magic to use this state for individual pages when building them.
- nested state variables in template strings eg {{state.test.deep.var}} now work.
- replace parse5 with posthtml.
- custom markdown and custom html renderers added.
- @magic-modules in markdown and html can have keys that are arrays or objects now.
if the value of a ${state.variable} in a template string is an array, this array gets join(' ')ed
render/html: empty arrays and objects return an empty string.
render/markdown.codespan: do not show linenumbers for codespans.
- handle " escapes.
- string delimiters ', " AND ` in a string do not error, get escaped instead.
- actually escape multiple html entities in a string, not just the first occurrence
update dependencies
update dependencies
update prettier, @magic/cli
Link and Img do not get wrapped in a paragraph (anymore)
update marked and prettier
update dependencies
- bump required node version to 14.2.0
- update dependencies
- update dependencies
- FIX: command line interface was broken.
- update dependencies
- move magic-modules/no-spy to devDependencies
update dependencies
update dependencies
update dependencies
update dependencies
- update dependencies
- fix markdown html handling changes
- update dependencies
update dependencies
update dependencies
- bump required node version to 14.15.4
- update dependencies
update dependencies
update dependencies (marked)
update dependencies (posthtml-parser)
remove call to undefined cleanUrl from markdown.image
update dependencies
- if the array returned by transmute has a length of 1, return that item instead
- update dependencies
do return arrays in all cases. adapt tests to accomodate for that
update dependencies
update dependencies to avoid circular dependencies in @magic/types
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
update dependencies
...