Home / File/ html-parser.ts — vue Source File

html-parser.ts — vue Source File

Architecture documentation for html-parser.ts, a typescript file in the vue codebase. 4 imports, 1 dependents.

File typescript CompilerSFC TemplateTransformer 4 imports 1 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  3c4fa7b0_c9a8_3b62_4edb_edb8676e969a["html-parser.ts"]
  156bf2e1_8a13_f22d_5437_54f14bcef8fa["util"]
  3c4fa7b0_c9a8_3b62_4edb_edb8676e969a --> 156bf2e1_8a13_f22d_5437_54f14bcef8fa
  ebc1ee8c_3788_d1a8_036c_147e190c81b1["util"]
  3c4fa7b0_c9a8_3b62_4edb_edb8676e969a --> ebc1ee8c_3788_d1a8_036c_147e190c81b1
  e2ab1319_857b_3d17_7c7a_2e8a814e3415["lang"]
  3c4fa7b0_c9a8_3b62_4edb_edb8676e969a --> e2ab1319_857b_3d17_7c7a_2e8a814e3415
  47ae9f26_59d1_fab2_349f_966f5d15495a["compiler"]
  3c4fa7b0_c9a8_3b62_4edb_edb8676e969a --> 47ae9f26_59d1_fab2_349f_966f5d15495a
  320ee0f4_351d_a6b2_1c1c_f0f6f42fb987["index.ts"]
  320ee0f4_351d_a6b2_1c1c_f0f6f42fb987 --> 3c4fa7b0_c9a8_3b62_4edb_edb8676e969a
  style 3c4fa7b0_c9a8_3b62_4edb_edb8676e969a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Not type-checking this file because it's mostly vendor code.
 */

/*!
 * HTML Parser By John Resig (ejohn.org)
 * Modified by Juriy "kangax" Zaytsev
 * Original code by Erik Arvidsson (MPL-1.1 OR Apache-2.0 OR GPL-2.0-or-later)
 * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
 */

import { makeMap, no } from 'shared/util'
import { isNonPhrasingTag } from 'web/compiler/util'
import { unicodeRegExp } from 'core/util/lang'
import { ASTAttr, CompilerOptions } from 'types/compiler'

// Regular Expressions for parsing tags and attributes
const attribute =
  /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/
const dynamicArgAttribute =
  /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/
const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`
const qnameCapture = `((?:${ncname}\\:)?${ncname})`
const startTagOpen = new RegExp(`^<${qnameCapture}`)
const startTagClose = /^\s*(\/?)>/
const endTag = new RegExp(`^<\\/${qnameCapture}[^>]*>`)
const doctype = /^<!DOCTYPE [^>]+>/i
// #7298: escape - to avoid being passed as HTML comment when inlined in page
const comment = /^<!\--/
const conditionalComment = /^<!\[/

// Special Elements (can contain anything)
export const isPlainTextElement = makeMap('script,style,textarea', true)
const reCache = {}

const decodingMap = {
  '&lt;': '<',
  '&gt;': '>',
  '&quot;': '"',
  '&amp;': '&',
  '&#10;': '\n',
  '&#9;': '\t',
  '&#39;': "'"
}
const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g
const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g

// #5992
const isIgnoreNewlineTag = makeMap('pre,textarea', true)
const shouldIgnoreFirstNewline = (tag, html) =>
  tag && isIgnoreNewlineTag(tag) && html[0] === '\n'

function decodeAttr(value, shouldDecodeNewlines) {
  const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr
  return value.replace(re, match => decodingMap[match])
}

export interface HTMLParserOptions extends CompilerOptions {
  start?: (
    tag: string,
// ... (282 more lines)

Domain

Subdomains

Dependencies

  • compiler
  • lang
  • util
  • util

Frequently Asked Questions

What does html-parser.ts do?
html-parser.ts is a source file in the vue codebase, written in typescript. It belongs to the CompilerSFC domain, TemplateTransformer subdomain.
What functions are defined in html-parser.ts?
html-parser.ts defines 6 function(s): content, decodeAttr, parseHTML, shouldIgnoreFirstNewline, tag, text.
What does html-parser.ts depend on?
html-parser.ts imports 4 module(s): compiler, lang, util, util.
What files import html-parser.ts?
html-parser.ts is imported by 1 file(s): index.ts.
Where is html-parser.ts in the architecture?
html-parser.ts is located at src/compiler/parser/html-parser.ts (domain: CompilerSFC, subdomain: TemplateTransformer, directory: src/compiler/parser).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free