source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* texi2mdoc: Convert `--' and `---' to en-dash and em-dash, respectively,
@ 2015-03-05 15:18 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2015-03-05 15:18 UTC (permalink / raw)
  To: source

Log Message:
-----------
Convert `--' and `---' to en-dash and em-dash, respectively, and ensure that
this (and the other conversations) don't occur in literal mode.
Also make sure that @code{} switches on literal mode.

Modified Files:
--------------
    texi2mdoc:
        main.c
        util.c

Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/main.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -Lmain.c -Lmain.c -u -p -r1.62 -r1.63
--- main.c
+++ main.c
@@ -755,11 +755,15 @@ doinline(struct texi *p, enum texicmd cm
 
 	teximacroopen(p, macro);
 	p->seenws = 0;
+	if (TEXICMD_CODE == cmd)
+		p->literal++;
 	if (TEXICMD_SC == cmd)
 		p->uppercase++;
 	parsebracket(p, pos, 0);
 	if (TEXICMD_SC == cmd)
 		p->uppercase--;
+	if (TEXICMD_CODE == cmd)
+		p->literal--;
 	texipunctuate(p, pos);
 	teximacroclose(p);
 }
Index: util.c
===================================================================
RCS file: /home/cvs/mdocml/texi2mdoc/util.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -Lutil.c -Lutil.c -u -p -r1.27 -r1.28
--- util.c
+++ util.c
@@ -597,7 +597,26 @@ parseword(struct texi *p, size_t *pos, c
 		}
 		if ('\0' != extra && BUF(p)[*pos] == extra)
 			return;
-		if (*pos < BUFSZ(p) - 1 && 
+
+		if (p->literal) {
+			texiputchar(p, BUF(p)[*pos]);
+			advance(p, pos);
+			continue;
+		}
+
+		if (*pos < BUFSZ(p) - 2 && 
+			 '-' == BUF(p)[*pos] && 
+			 '-' == BUF(p)[*pos + 1] && 
+			 '-' == BUF(p)[*pos + 2]) {
+			texiputchars(p, "\\(em");
+			advance(p, pos);
+			advance(p, pos);
+		} else if (*pos < BUFSZ(p) - 1 && 
+			 '-' == BUF(p)[*pos] && 
+			 '-' == BUF(p)[*pos + 1]) {
+			texiputchars(p, "\\(en");
+			advance(p, pos);
+		} else if (*pos < BUFSZ(p) - 1 && 
 			 '`' == BUF(p)[*pos] && 
 			 '`' == BUF(p)[*pos + 1]) {
 			texiputchars(p, "\\(lq");
@@ -609,6 +628,7 @@ parseword(struct texi *p, size_t *pos, c
 			advance(p, pos);
 		} else
 			texiputchar(p, BUF(p)[*pos]);
+
 		advance(p, pos);
 	}
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-05 15:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 15:18 texi2mdoc: Convert `--' and `---' to en-dash and em-dash, respectively, kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).