mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-09 21:28:43 +08:00
This also adds CC-BY-4.0 to the list of accepted licenses. DISABLE_THIRD_PARTY_CHECK=update dependencies Bug: chromium:1083142 Change-Id: I8612de2fba52dae32eeb71af79d5aacfde52142b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2220097 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Mathias Bynens <mathias@chromium.org>
52 lines
962 B
JavaScript
52 lines
962 B
JavaScript
'use strict'
|
|
|
|
var repeat = require('repeat-string')
|
|
|
|
module.exports = heading
|
|
|
|
var lineFeed = '\n'
|
|
var space = ' '
|
|
var numberSign = '#'
|
|
var dash = '-'
|
|
var equalsTo = '='
|
|
|
|
// Stringify a heading.
|
|
//
|
|
// In `setext: true` mode and when `depth` is smaller than three, creates a
|
|
// setext header:
|
|
//
|
|
// ```markdown
|
|
// Foo
|
|
// ===
|
|
// ```
|
|
//
|
|
// Otherwise, an ATX header is generated:
|
|
//
|
|
// ```markdown
|
|
// ### Foo
|
|
// ```
|
|
//
|
|
// In `closeAtx: true` mode, the header is closed with hashes:
|
|
//
|
|
// ```markdown
|
|
// ### Foo ###
|
|
// ```
|
|
function heading(node) {
|
|
var self = this
|
|
var depth = node.depth
|
|
var setext = self.options.setext
|
|
var closeAtx = self.options.closeAtx
|
|
var content = self.all(node).join('')
|
|
var prefix
|
|
|
|
if (setext && depth < 3) {
|
|
return (
|
|
content + lineFeed + repeat(depth === 1 ? equalsTo : dash, content.length)
|
|
)
|
|
}
|
|
|
|
prefix = repeat(numberSign, node.depth)
|
|
|
|
return prefix + space + content + (closeAtx ? space + prefix : '')
|
|
}
|