@tamagui/code-to-html 1.0.1-rc.5 → 1.0.1-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/code-to-html",
3
- "version": "1.0.1-rc.5",
3
+ "version": "1.0.1-rc.6",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
@@ -13,8 +13,8 @@
13
13
  "scripts": {
14
14
  "build": "tamagui-build --bundle",
15
15
  "watch": "tamagui-build --bundle --watch",
16
- "lint": "eslint src",
17
- "lint:fix": "yarn lint --fix",
16
+ "lint": "../../node_modules/.bin/rome check src",
17
+ "lint:fix": "../../node_modules/.bin/rome check --apply-suggested src",
18
18
  "clean": "tamagui-build clean",
19
19
  "clean:build": "tamagui-build clean:build"
20
20
  },
@@ -30,7 +30,7 @@
30
30
  "url": "^0.11.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@tamagui/build": "^1.0.1-rc.5"
33
+ "@tamagui/build": "^1.0.1-rc.6"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public"
@@ -42,7 +42,7 @@ const lineNumberify = function lineNumberify(ast, lineNum = 1) {
42
42
  result.nodes.push(node)
43
43
  return result
44
44
  },
45
- { nodes: [], lineNumber: lineNumber }
45
+ { nodes: [], lineNumber: lineNumber },
46
46
  )
47
47
  }
48
48
 
@@ -75,7 +75,8 @@ const wrapLines = function wrapLines(ast: any[], linesToHighlight) {
75
75
  properties: {
76
76
  dataLine: line,
77
77
  className: 'highlight-line',
78
- dataHighlighted: linesToHighlight.includes(line) || highlightAll ? 'true' : 'false',
78
+ dataHighlighted:
79
+ linesToHighlight.includes(line) || highlightAll ? 'true' : 'false',
79
80
  },
80
81
  children,
81
82
  lineNumber: line,
@@ -96,11 +97,13 @@ const applyMultilineFix = function (ast) {
96
97
 
97
98
  // Fix JSX issue
98
99
  html = html.replace(MULTILINE_TOKEN_SPAN, (match, token) =>
99
- match.replace(/\n/g, `</span>\n<span class="token ${token}">`)
100
+ match.replace(/\n/g, `</span>\n<span class="token ${token}">`),
100
101
  )
101
102
 
102
103
  // HTML to AST
103
- const hast = unified().use(parse, { emitParseErrors: true, fragment: true }).parse(html)
104
+ const hast = unified()
105
+ .use(parse, { emitParseErrors: true, fragment: true })
106
+ .parse(html)
104
107
 
105
108
  return hast.children
106
109
  }
@@ -7,7 +7,12 @@ const CALLOUT = /__(.*?)__/g
7
7
 
8
8
  export function highlightWord(code) {
9
9
  const html = toHtml(code)
10
- const result = html.replace(CALLOUT, (_, text) => `<span class="highlight-word">${text}</span>`)
11
- const hast = unified().use(parse, { emitParseErrors: true, fragment: true }).parse(result)
10
+ const result = html.replace(
11
+ CALLOUT,
12
+ (_, text) => `<span class="highlight-word">${text}</span>`,
13
+ )
14
+ const hast = unified()
15
+ .use(parse, { emitParseErrors: true, fragment: true })
16
+ .parse(result)
12
17
  return hast.children
13
18
  }
package/src/index.ts CHANGED
@@ -10,7 +10,11 @@ import { highlightWord } from './highlightWord'
10
10
  refractor.register(tsx)
11
11
  refractor.register(css)
12
12
 
13
- export function codeToHTML(source: string, language: 'tsx' | 'css' | string, line = '0') {
13
+ export function codeToHTML(
14
+ source: string,
15
+ language: 'tsx' | 'css' | string,
16
+ line = '0',
17
+ ) {
14
18
  let result: any = refractor.highlight(source, language)
15
19
  result = highlightLine(result, rangeParser(line))
16
20
  result = highlightWord(result)