diff options
| author | Henry Jameson <me@hjkos.com> | 2021-06-12 19:47:23 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2021-06-12 19:54:30 +0300 |
| commit | cd4455675024a3dfc8930184114d5f92438d0466 (patch) | |
| tree | 14a11f546ab86fc1f5a2d288344f3ff7c7e246a5 /src/services/html_converter/html_line_converter.service.js | |
| parent | ca6c7d5b10e48299dcb0ee65248de14f27ed78c8 (diff) | |
restructure and tests
squash! restructure and tests
Diffstat (limited to 'src/services/html_converter/html_line_converter.service.js')
| -rw-r--r-- | src/services/html_converter/html_line_converter.service.js | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/services/html_converter/html_line_converter.service.js b/src/services/html_converter/html_line_converter.service.js index d8f5ecb8..e448d5cd 100644 --- a/src/services/html_converter/html_line_converter.service.js +++ b/src/services/html_converter/html_line_converter.service.js @@ -1,3 +1,5 @@ +import { getTagName } from './utility.service.js' + /** * This is a tiny purpose-built HTML parser/processor. This basically detects * any type of visual newline and converts entire HTML into a array structure. @@ -26,12 +28,6 @@ export const convertHtmlToLines = (html) => { let textBuffer = '' // Current line content let tagBuffer = null // Current tag buffer, if null = we are not currently reading a tag - // Extracts tag name from tag, i.e. <span a="b"> => span - const getTagName = (tag) => { - const result = /(?:<\/(\w+)>|<(\w+)\s?[^/]*?\/?>)/gi.exec(tag) - return result && (result[1] || result[2]) - } - const flush = () => { // Processes current line buffer, adds it to output buffer and clears line buffer if (textBuffer.trim().length > 0 && !level.some(l => ignoredTags.has(l))) { buffer.push({ text: textBuffer }) |
