Code Snippets and Patches of 2015

I am currently writing some documentation for a windows program. For that I found halibut a very useful tool, but it doesn't create image tags for the resulting chm files :(

So then, I wrote a small patch which does what I need... but of cause, it's more a small hack then a real patch, cause the new \img{someimage.png} tag is currently only working when running halibut with html output.

A really cool feature would be, when also the Postscript and the PDF Output would work with it... but that would need to much time, that I currently do not have :(

diff -urN halibut-1.1/bk_html.c halibut-1.1-img/bk_html.c
--- halibut-1.1/bk_html.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/bk_html.c	2015-03-20 19:50:03.000000000 +0100
@@ -1547,6 +1547,7 @@
 				element_empty(&ho, "br");
 			    html_nl(&ho);
 
+			    
 			    html_words(&ho, entry->text, MARKUP|LINKS,
 				       f, keywords, &conf);
 
@@ -1731,6 +1732,7 @@
 		"Compiled file=%s\n"
 		"Default Window=main\n"
 		"Default topic=%s\n"
+		"Default Font=Segoe UI,10,0\n"
 		"Display compile progress=Yes\n"
 		"Full-text search=Yes\n"
 		"Title=", conf.chm_filename, files.head->filename);
@@ -1771,7 +1773,7 @@
 		 * buttons: 7/8 (which do nothing useful), and 21/22
 		 * (which work). (Neither of these are exposed in the HHW
 		 * UI, but they work fine in HH.) We use the latter. */
-		"0x60304e,,,,,,,,0\n",
+		"0x70304e,,,,,,,,0\n",
 		conf.hhc_filename ? conf.hhc_filename : "",
 		hhk_filename ? hhk_filename : "",
 		files.head->filename);
@@ -2216,6 +2218,12 @@
     int style, type;
 
     for (w = words; w; w = w->next) switch (w->type) {
+      case word_Image:
+        if (w->text) {
+	    element_open(ho, "img");
+	    element_attr_w(ho, "src", w->text);
+	}
+	break;
       case word_HyperLink:
 	if (flags & LINKS) {
 	    element_open(ho, "a");
diff -urN halibut-1.1/bk_info.c halibut-1.1-img/bk_info.c
--- halibut-1.1/bk_info.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/bk_info.c	2015-03-20 13:54:12.000000000 +0100
@@ -870,6 +870,7 @@
     for (; words && words != end; words = words->next) switch (words->type) {
       case word_HyperLink:
       case word_HyperEnd:
+      case word_Image:
       case word_XrefEnd:
       case word_IndexRef:
 	break;
diff -urN halibut-1.1/bk_man.c halibut-1.1-img/bk_man.c
--- halibut-1.1/bk_man.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/bk_man.c	2015-03-20 13:54:12.000000000 +0100
@@ -582,6 +582,7 @@
     for (; text && text != end; text = text->next) switch (text->type) {
       case word_HyperLink:
       case word_HyperEnd:
+      case word_Image:
       case word_UpperXref:
       case word_LowerXref:
       case word_XrefEnd:
diff -urN halibut-1.1/bk_paper.c halibut-1.1-img/bk_paper.c
--- halibut-1.1/bk_paper.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/bk_paper.c	2015-03-20 13:54:12.000000000 +0100
@@ -1626,6 +1626,7 @@
     switch (word->type) {
       case word_HyperLink:
       case word_HyperEnd:
+      case word_Image:
       case word_UpperXref:
       case word_LowerXref:
       case word_PageXref:
diff -urN halibut-1.1/bk_pdf.c halibut-1.1-img/bk_pdf.c
--- halibut-1.1/bk_pdf.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/bk_pdf.c	2015-03-20 13:54:12.000000000 +0100
@@ -1000,6 +1000,7 @@
 	switch (words->type) {
 	  case word_HyperLink:
 	  case word_HyperEnd:
+	  case word_Image:
 	  case word_UpperXref:
 	  case word_LowerXref:
 	  case word_XrefEnd:
diff -urN halibut-1.1/bk_ps.c halibut-1.1-img/bk_ps.c
--- halibut-1.1/bk_ps.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/bk_ps.c	2015-03-20 13:54:12.000000000 +0100
@@ -325,6 +325,7 @@
 	switch (words->type) {
 	  case word_HyperLink:
 	  case word_HyperEnd:
+	  case word_Image:
 	  case word_UpperXref:
 	  case word_LowerXref:
 	  case word_XrefEnd:
diff -urN halibut-1.1/bk_text.c halibut-1.1-img/bk_text.c
--- halibut-1.1/bk_text.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/bk_text.c	2015-03-20 13:54:12.000000000 +0100
@@ -519,6 +519,7 @@
     for (; text && text != end; text = text->next) switch (text->type) {
       case word_HyperLink:
       case word_HyperEnd:
+      case word_Image:
       case word_UpperXref:
       case word_LowerXref:
       case word_XrefEnd:
diff -urN halibut-1.1/bk_whlp.c halibut-1.1-img/bk_whlp.c
--- halibut-1.1/bk_whlp.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/bk_whlp.c	2015-03-20 13:54:12.000000000 +0100
@@ -710,6 +710,7 @@
     for (; text; text = text->next) switch (text->type) {
       case word_HyperLink:
       case word_HyperEnd:
+      case word_Image:
 	break;
 
       case word_IndexRef:
diff -urN halibut-1.1/halibut.h halibut-1.1-img/halibut.h
--- halibut-1.1/halibut.h	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/halibut.h	2015-03-20 13:54:12.000000000 +0100
@@ -169,6 +169,7 @@
     word_IndexRef,		       /* (always an invisible one) */
     word_HyperLink,		       /* (invisible) */
     word_HyperEnd,		       /* (also invisible; no text) */
+    word_Image,			       /* (invisible) */
     /*
      * Back ends may define their own word types beyond here, in
      * case they need to use them internally.
diff -urN halibut-1.1/input.c halibut-1.1-img/input.c
--- halibut-1.1/input.c	2014-12-19 11:03:18.000000000 +0100
+++ halibut-1.1-img/input.c	2015-03-20 13:54:12.000000000 +0100
@@ -229,6 +229,7 @@
     c_define,			       /* macro definition */
     c_dt,			       /* description list: described thing */
     c_e,			       /* emphasis */
+    c_img,			       /* image */
     c_i,			       /* visible index mark */
     c_ii,			       /* uncapitalised visible index mark */
     c_k,			       /* uncapitalised cross-reference */
@@ -303,6 +304,7 @@
 	{"e", c_e},		       /* emphasis */
 	{"i", c_i},		       /* visible index mark */
 	{"ii", c_ii},		       /* uncapitalised visible index mark */
+	{"img", c_img},		       /* image \img{file.png} */
 	{"k", c_k},		       /* uncapitalised cross-reference */
 	{"lcont", c_lcont},	       /* continuation para(s) for list item */
 	{"n", c_n},		       /* numbered list */
@@ -1034,6 +1036,7 @@
          *  \q
 	 *  \u
 	 *  \W
+	 *  \img
 	 *  \date
 	 *  \\ \{ \}
 	 */
@@ -1282,6 +1285,7 @@
 		  case c_K:
 		  case c_k:
 		  case c_W:
+		  case c_img:
 		  case c_date:
 		    /*
 		     * Keyword, hyperlink, or \date. We expect a
@@ -1296,6 +1300,8 @@
 			wd.type = word_LowerXref;
 		    else if (t.cmd == c_W)
 			wd.type = word_HyperLink;
+		    else if (t.cmd == c_img)
+			wd.type = word_Image;
 		    else
 			wd.type = word_Normal;
 		    dtor(t), t = get_token(in);

halibut-1.1-img.diff

Last modified on 2015-04-25 at 12:17
netcup.de