Update a rule.
This commit is contained in:
parent
5d4d388fe8
commit
c323698b2a
@ -9,10 +9,10 @@ const html = await Astro.slots.render("default");
|
|||||||
// 3. If a line ends without [a-zA-Z] and its next line starts with [a-zA-Z],
|
// 3. If a line ends without [a-zA-Z] and its next line starts with [a-zA-Z],
|
||||||
// add a heading space to the next line.
|
// add a heading space to the next line.
|
||||||
// 4. If a line does not start in ASCII chars, join it to its previous line.
|
// 4. If a line does not start in ASCII chars, join it to its previous line.
|
||||||
// 5. If a line starts with <strong> or <em>, add a heading space to this
|
// 5. If a line starts with <strong> or <em> or <a>, add a heading space to
|
||||||
// line.
|
// this line.
|
||||||
// 6. If a line ends with </strong> or </em>, add a tailing space to this
|
// 6. If a line ends with </strong> or </em> or </a>, add a tailing space to
|
||||||
// line.
|
// this line.
|
||||||
// This is important in using one newline character to wrap Chinese.
|
// This is important in using one newline character to wrap Chinese.
|
||||||
const arr = html.split("\n");
|
const arr = html.split("\n");
|
||||||
let articleHTMLFinal = arr[0];
|
let articleHTMLFinal = arr[0];
|
||||||
@ -47,11 +47,11 @@ for (let i = 1; i < arr.length; i++) {
|
|||||||
arr[i] += " ";
|
arr[i] += " ";
|
||||||
}
|
}
|
||||||
// rule 5
|
// rule 5
|
||||||
if (arr[i].match(/^(<em>|<strong>)/) !== null){
|
if (arr[i].match(/^(<em>|<strong>|<a>)/) !== null){
|
||||||
arr[i] = " " + arr[i];
|
arr[i] = " " + arr[i];
|
||||||
}
|
}
|
||||||
// rule 6
|
// rule 6
|
||||||
if (arr[i].match(/(<\/em>|<\/strong>)$/) !== null){
|
if (arr[i].match(/(<\/em>|<\/strong>|<\/a>)$/) !== null){
|
||||||
arr[i] = arr[i] + " ";
|
arr[i] = arr[i] + " ";
|
||||||
}
|
}
|
||||||
// -------- combine lines
|
// -------- combine lines
|
||||||
|
Loading…
Reference in New Issue
Block a user