shithub: epublish

Download patch

ref: 069cd7b7ff6a865a25074245fb200fb924edfdf0
parent: e59909df1a72aff2c7bd8766e2c6237c78d693a8
author: sirjofri <sirjofri@sirjofri.de>
date: Wed Sep 8 11:57:01 EDT 2021

adds output-specific comments with [[[ms [[[ebook and ]]] (and commenting feature)

also fixes doubled paragraph lines

--- a/test.txt
+++ b/test.txt
@@ -5,6 +5,14 @@
 Hello World
 Welcome here.
 
+[[[ms
+ms exclusive
+]]]
+
+[[[ebook
+ebook exclusive
+]]]
+
 # second chapter
 
 Content of second
--- a/txt2ebook
+++ b/txt2ebook
@@ -33,6 +33,30 @@
 	next
 }
 
+$1 ~ /^\[\[\[ebook/ {
+	ismsblock = 1
+	next
+}
+
+$1 ~ /^\]\]\]ebook/ {
+	ismsblock = 0
+	next
+}
+
+$1 ~ /^\[\[\[/ {
+	ignore = 1
+	next
+}
+
+$1 ~ /^\]\]\]/ {
+	ignore = 0
+	next
+}
+
+ignore {
+	next
+}
+
 $1 ~ /^#+$/ {
 	l = length($1)
 	$1 = ""
@@ -86,6 +110,7 @@
 	print parsed($0)
 	previousempty = 0
 	isparagraph = 1
+	next
 }
 
 !previousempty {
--- a/txt2ms
+++ b/txt2ms
@@ -24,6 +24,30 @@
 	nextline = 1
 }
 
+$1 ~ /^\[\[\[ms/ {
+	ismsblock = 1
+	next
+}
+
+$1 ~ /^\]\]\]ms/ {
+	ismsblock = 0
+	next
+}
+
+$1 ~ /^\[\[\[/ {
+	ignore = 1
+	next
+}
+
+$1 ~ /^\]\]\]/ {
+	ignore = 0
+	next
+}
+
+ignore {
+	next
+}
+
 $1 ~ /^#+$/ {
 	l = length($1)
 	$1 = ""
@@ -30,15 +54,6 @@
 	sub(/^[ \t]*/, "")
 	printf ".NH %d\n.LG\n%s\n.NL\n", l, parsed($0)
 	printf ".XS %d \"%s\"\n", l, parsed($0)
-	istitle = 1
-	nextline = 1
-}
-
-$1 ~ /^\$+$/ {
-	$1 = ""
-	sub(/^[ \t]*/, "")
-	printf ".SH\n.LG\n%s\n.NL\n", parsed($0)
-	printf ".XS 0 \"%s\"\n", parsed($0)
 	istitle = 1
 	nextline = 1
 }