Paragraph break placeholder in ktxt2
This commit is contained in:
@@ -60,6 +60,10 @@
|
||||
(elements.push (Block block))))
|
||||
elements))
|
||||
|
||||
// To save window space after each block editor, ¶ can be used in place of \n\n
|
||||
(function :String applySpecialChars [:String text]
|
||||
(text.replace "¶" "\n\n"))
|
||||
|
||||
// Return [sourceFile outputFile]
|
||||
(function :Array<String> extractFileContents [:Stream fileStream :String->Dynamic reportError]
|
||||
(let [&mut sourceText ""
|
||||
@@ -78,7 +82,7 @@
|
||||
(try (interp.evalKiss "\"${output}\"")
|
||||
(catch [error] (reportError "Export templating error $error") (throw error))))))
|
||||
(otherwise)))
|
||||
[sourceText outputText]))
|
||||
(.map [sourceText outputText] applySpecialChars)))
|
||||
|
||||
(function :Map<String,KTxt2Conversion> validConversions [:Array<KTxt2Conversion> conversions :String sourceFile :String outputFile :String source]
|
||||
(let [validMap (new Map)]
|
||||
|
@@ -8,6 +8,7 @@ import js.lib.Promise;
|
||||
import sys.io.File;
|
||||
|
||||
using haxe.io.Path;
|
||||
using StringTools;
|
||||
|
||||
typedef MessageFromEditor = {
|
||||
type:String,
|
||||
|
@@ -9,6 +9,11 @@
|
||||
|
||||
(defNew [&prop :ExtensionContext context])
|
||||
|
||||
(method :String insertSpecialChars [:String text]
|
||||
(if (text.endsWith "\n\n")
|
||||
(+ (text.substr 0 (- text.length 2)) "¶")
|
||||
text))
|
||||
|
||||
(method :Promise<Void> resolveCustomTextEditor [:TextDocument document :WebviewPanel webviewPanel :CancellationToken _token]
|
||||
(set webviewPanel.webview.options (object enableScripts true))
|
||||
(set webviewPanel.webview.html (htmlForWebview webviewPanel.webview))
|
||||
@@ -36,7 +41,7 @@
|
||||
(infoMessage message))
|
||||
((objectWith [type "replace"] text start end)
|
||||
(makeEdit
|
||||
->edit (edit.replace document.uri (rangeFromStartEnd start end) text)))
|
||||
->edit (edit.replace document.uri (rangeFromStartEnd start end) (insertSpecialChars text))))
|
||||
((objectWith [type "insertBefore"] text position)
|
||||
(makeEdit
|
||||
->edit (edit.insert document.uri (streamPosToOffsetDocumentPos position -KTxt2.blockStartEnd.length) text)))
|
||||
|
Reference in New Issue
Block a user