Feature/csv table (#500)

- added csv-replacer
- changed highlghted-code plugin:
     each replacer extracts what he need from the data-extra attribute now
- changed CHANGELOG.md

Co-authored-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Philip Molares 2020-08-29 15:55:42 +02:00 committed by GitHub
parent 6919f5e4fb
commit d482065d72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 157 additions and 12 deletions

View file

@ -1,7 +1,7 @@
import { DomElement } from 'domhandler'
import React from 'react'
import { HighlightedCode } from './highlighted-code/highlighted-code'
import { ComponentReplacer } from '../ComponentReplacer'
import { HighlightedCode } from './highlighted-code/highlighted-code'
export class HighlightedCodeReplacer implements ComponentReplacer {
private lastLineNumber = 0;
@ -12,11 +12,20 @@ export class HighlightedCodeReplacer implements ComponentReplacer {
}
const language = codeNode.attribs['data-highlight-language']
const showLineNumbers = codeNode.attribs['data-show-line-numbers'] !== undefined
const startLineNumberAttribute = codeNode.attribs['data-start-line-number']
const extraData = codeNode.attribs['data-extra']
const extraInfos = /(=(\d*|\+))?(!?)/.exec(extraData)
let showLineNumbers = false
let startLineNumberAttribute = ''
let wrapLines = false
if (extraInfos) {
showLineNumbers = extraInfos[0] !== undefined
startLineNumberAttribute = extraInfos[1]
wrapLines = extraInfos[2] !== undefined
}
const startLineNumber = startLineNumberAttribute === '+' ? this.lastLineNumber : (parseInt(startLineNumberAttribute) || 1)
const wrapLines = codeNode.attribs['data-wrap-lines'] !== undefined
const code = codeNode.children[0].data as string
if (showLineNumbers) {