htmldoc-ext
v1.0.2
Published
Extract html comments.
Downloads
15
Maintainers
Readme
htmldoc-ext
Usage
Extract annotation content. You are free to specify the annotation.
const htmldoc = require('htmldoc-ext')
const filepath = './index.html'
<!--
@description descriptiondescription
description
descriptiondescription
@testtest notenotenote
@date 2018/08/26
@url
- https://111.com
- https://222.com
- https://333.com
@name index.html
@list ・1111111 ・2222222 ・3333333
-->
<!DOCTYPE html>
<html>
<head>
<title>./index.html</title>
</head>
<body>
</body>
</html>
Single item
let test = htmldoc.content(filepath, 'testtest')
// -> notenotenote
let description = htmldoc.content(filepath, 'description')
// -> descriptiondescription\ndescription\ndescriptiondescription
let date = htmldoc.content(filepath, 'date')
// -> 2018/08/26
Multiple items
let url = htmldoc.list(filepath, 'url')
// -> ["https://111.com", "https://222.com", "https://333.com"]
let list = htmldoc.list(filepath, 'list', '・')
// -> ["1111111", "2222222", "3333333"]
Convert to Preferred list style
let array = ["1111111", "2222222", "3333333"]
let circleList = htmldoc.itemize(array)
// -> "・1111111\n・2222222\n・3333333"
let arrowList = htmldoc.itemize(array, '> ')
// -> "> 1111111\n> 2222222\n> 3333333"