literate-ts
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "literate-ts", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Code samples that scale", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -138,2 +138,6 @@ # literate-ts | ||
You may also use `// #id` or `// verifier:directive` as an alternative form. | ||
This is primarily useful if you want to prepend a code sample that's hidden inside an | ||
HTML comment. | ||
See below for a complete list of directives. | ||
@@ -140,0 +144,0 @@ |
@@ -6,2 +6,4 @@ import {matchAndExtract} from './utils'; | ||
const EXTRACT_DIRECTIVE = /<!-- verifier:(.*) -->/; | ||
const ALT_EXTRACT_ID = /^\/\/ #([^ ]+)$/; | ||
const ALT_EXTRACT_DIRECTIVE = /^\/\/ verifier:(.*)$/; | ||
const TOP_HEADER = /^#{1,3} (.*)$/; | ||
@@ -14,5 +16,6 @@ | ||
const line = lines[i]; | ||
const id = matchAndExtract(EXTRACT_ID, line); | ||
const id = matchAndExtract(EXTRACT_ID, line) || matchAndExtract(ALT_EXTRACT_ID, line); | ||
const header = matchAndExtract(TOP_HEADER, line); | ||
const directive = matchAndExtract(EXTRACT_DIRECTIVE, line); | ||
const directive = | ||
matchAndExtract(EXTRACT_DIRECTIVE, line) || matchAndExtract(ALT_EXTRACT_DIRECTIVE, line); | ||
@@ -19,0 +22,0 @@ if (id) { |
import fs from 'fs'; | ||
import glob from 'glob'; | ||
import path from 'path'; | ||
@@ -80,15 +82,7 @@ import {dedent} from '../utils'; | ||
test('snapshot', () => { | ||
const dir = './src/test/inputs'; | ||
const inputFiles = glob.sync('./src/test/inputs/*.asciidoc'); | ||
// TODO(danvk): use a glob here | ||
const inputs = ['doc1', 'noid', 'prepend', 'prepend-multiple', 'skip', 'multilinetype']; | ||
for (const input of inputs) { | ||
expect( | ||
extractSamples( | ||
fs.readFileSync(`${dir}/${input}.asciidoc`, 'utf8'), | ||
input, | ||
`${input}.asciidoc`, | ||
), | ||
).toMatchSnapshot(input); | ||
for (const inputFile of inputFiles) { | ||
const {base, name} = path.parse(inputFile); | ||
expect(extractSamples(fs.readFileSync(inputFile, 'utf8'), name, base)).toMatchSnapshot(name); | ||
} | ||
@@ -95,0 +89,0 @@ }); |
import fs from 'fs'; | ||
import glob from 'glob'; | ||
import path from 'path'; | ||
@@ -7,13 +9,9 @@ import {extractSamples} from '../code-sample'; | ||
it('should match snapshots', () => { | ||
const dir = './src/test/inputs'; | ||
const inputFiles = glob.sync('./src/test/inputs/*.md'); | ||
// TODO(danvk): use a glob here | ||
const inputs = ['doc1', 'noid', 'prepend', 'prepend-multiple', 'skip', 'multilinetype']; | ||
for (const input of inputs) { | ||
expect( | ||
extractSamples(fs.readFileSync(`${dir}/${input}.md`, 'utf8'), input, `${input}.md`), | ||
).toMatchSnapshot(input); | ||
for (const inputFile of inputFiles) { | ||
const {base, name} = path.parse(inputFile); | ||
expect(extractSamples(fs.readFileSync(inputFile, 'utf8'), name, base)).toMatchSnapshot(name); | ||
} | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
297
1
0
106476
49
2061