0.5.1 • Published 2 years ago

htmlat-nodejs v0.5.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Nodejs htmlat to html converter

Install

npm i --save htmlat-nodejs

Use

import {convert} from 'htmlat-nodejs'
const htmlStr = convert('(article){{(p){{my blog content here}}}}')

import {convertFile} from 'htmlat-nodejs'
convertFile('src/my-blogpost.semtext', 'dist/my-blogpost.html')

Wrapping content in a document

You can provide custom html to wrap your content with. E.g., with

<html>
    <head>
        <link rel="stylesheet" href="css/index.css">
    </head>
    <body>
        <main data-slot></main>
    </body>
</html>

your content will be placed inside the main element.

To provide the wrap:

convert('(p){{my content}}', '<html><head></head><body></body></html>')
convertFile('src/my-blogpost.semtext', 'dist/my-blogpost.html', 'src/custom-wrap.html')

Allowed tags

The following tags are allowed in a wrap: html, body, head, link, meta, header, nav, aside, main, div, script.

data-slot

The content will be placed inside the element, which has the data-slot attribute. The wrap must have an element with this attribute.

script

The script tags can only be used to import scripts (e.g., <script src="index.js"></script>). Any script that has content will be removed.

cli

htmlat-cli provides a nice cli for this module.

using paths in script src

sanitize-html won't allow simple paths (e.g., scripts/index.js) in the src attribute; it only allows urls. To be able to use such paths, you have to specify the path as part of a url, e.g. https://scripts/index.js and set the data-url-to-path attribute.

E.g., <script src="https://scripts/index.js" data-url-to-path></script>.

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago