1- import { blockTags , lineEndTags , newlineTags , verbatimTags } from "./docStructure" ;
2-
1+ import {
2+ blockTags ,
3+ lineEndTags ,
4+ newlineTags ,
5+ verbatimTags ,
6+ } from "./docStructure" ;
37
48// Function to join lines of text, preserving verbatim blocks.
59function joinLines ( fullText : string ) : string {
@@ -42,15 +46,14 @@ function joinLines(fullText: string): string {
4246 return joinedText ;
4347}
4448
45-
4649export function formatPretext (
4750 text : string ,
4851 options ?: {
4952 breakLines ?: "few" | "some" | "many" ;
5053 breakSentences ?: boolean ;
5154 insertSpaces ?: boolean ;
5255 tabSize ?: number ;
53- }
56+ } ,
5457) : string {
5558 // set default options
5659 const breakSentences = options ?. breakSentences ?? false ;
@@ -67,7 +70,7 @@ export function formatPretext(
6770 // start tag can be <tag>, <tag attr="val">, or <tag xmlns="..."> but shouldn't be self closing (no self closing tag would have xmlns in it)
6871 let startTag = new RegExp (
6972 "<" + btag + "(>|(\\s[^\\/]*?)>|(.*xmlns.*?)>)" ,
70- "g"
73+ "g" ,
7174 ) ;
7275 let endTag = new RegExp ( "<\\/" + btag + ">([\\s\\S]*?[.,!?;:]?)" , "g" ) ;
7376 allText = allText . replace ( startTag , "\n$&\n" ) ;
@@ -84,7 +87,6 @@ export function formatPretext(
8487 allText = allText . replace ( selfCloseTag , "$&\n" ) ;
8588 }
8689
87-
8890 // Set indent character to \t or a number of ss based on editor settings.
8991 let indentChar = "\t" ;
9092 if ( insertSpaces && typeof tabSize === "number" ) {
@@ -131,7 +133,7 @@ export function formatPretext(
131133 if ( breakSentences ) {
132134 trimmedLine = trimmedLine . replace (
133135 / \. \s + / g,
134- ".\n" + indentChar . repeat ( level )
136+ ".\n" + indentChar . repeat ( level ) ,
135137 ) ;
136138 }
137139 fixedLines . push ( indentChar . repeat ( level ) + trimmedLine ) ;
0 commit comments