[PATCH] Docs: fix handling of number signs in code blocks

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


diff --git a/docs/scripts/make_single.c b/docs/scripts/make_single.c
index 7dde3b4..240f1a8 100644
--- a/docs/scripts/make_single.c
+++ b/docs/scripts/make_single.c
@@ -34,19 +34,32 @@ void make_single_doc(int argc, char *argv[])
 static void preprocess(void)
 {
    dstr line;
+   bool code_block = false;
 
    while (d_getline(line)) {
-      /* Raise sections by one level. Top-most becomes the document title. */
-      if (line[0] == '#' && raise_sections) {
-         if (line[1] == ' ') {
-            line[0] = '%';
-         }
-         else {
-            char *p = strchr(line, ' ');
-            if (p) {
-               p[-1] = ' ';
+      /* Raise sections by one level. Top-most becomes the document title.
+         Don't do it within code blocks (~~~).
+      */
+      if (!code_block) {
+         if (line[0] == '#' && raise_sections) {
+            if (line[1] == ' ') {
+               line[0] = '%';
+            }
+            else {
+               char *p = strchr(line, ' ');
+               if (p) {
+                  p[-1] = ' ';
+               }
             }
          }
+         else if (!strncmp(line, "~~~", 3))
+            code_block = true;
+      }
+      else {
+         if (!strncmp(line, "~~~", 3))
+            code_block = false;
+         d_print(line);
+         continue;
       }
 
       /* Make sure there is a blank line between input files so paragraphs
diff --git a/docs/src/refman/acodec.txt b/docs/src/refman/acodec.txt
index 90833c9..e13a741 100644
--- a/docs/src/refman/acodec.txt
+++ b/docs/src/refman/acodec.txt
@@ -4,7 +4,7 @@ These functions are declared in the following header file.
 Link with allegro_acodec.
 
 ~~~~c
- #include <allegro5/allegro_acodec.h>
+#include <allegro5/allegro_acodec.h>
 ~~~~
 
 ## API: al_init_acodec_addon
diff --git a/docs/src/refman/audio.txt b/docs/src/refman/audio.txt
index 118db08..d32955c 100644
--- a/docs/src/refman/audio.txt
+++ b/docs/src/refman/audio.txt
@@ -4,7 +4,7 @@ These functions are declared in the following header file.
 Link with allegro_audio.
 
 ~~~~c
- #include <allegro5/allegro_audio.h>
+#include <allegro5/allegro_audio.h>
 ~~~~
 
 ## Audio types
diff --git a/docs/src/refman/color.txt b/docs/src/refman/color.txt
index b4f26cb..00437bb 100644
--- a/docs/src/refman/color.txt
+++ b/docs/src/refman/color.txt
@@ -4,7 +4,7 @@ These functions are declared in the following header file.
 Link with allegro_color.
 
 ~~~~c
- #include <allegro5/allegro_color.h>
+#include <allegro5/allegro_color.h>
 ~~~~
 
 ## API: al_color_cmyk
diff --git a/docs/src/refman/config.txt b/docs/src/refman/config.txt
index e33c042..5d65f5b 100644
--- a/docs/src/refman/config.txt
+++ b/docs/src/refman/config.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 Allegro supports reading and writing of configuration files with a
@@ -32,7 +32,7 @@ declarations belong to the global section. Sections do not nest.
 Here is an example configuration file:
 
 ~~~ini
-## Monster description
+# Monster description
 monster name = Allegro Developer
 
 [weapon 0]
diff --git a/docs/src/refman/direct3d.txt b/docs/src/refman/direct3d.txt
index cb9aa3f..0c648f3 100644
--- a/docs/src/refman/direct3d.txt
+++ b/docs/src/refman/direct3d.txt
@@ -3,7 +3,7 @@
 These functions are declared in the following header file:
 
 ~~~~c
- #include <allegro5/allegro_direct3d.h>
+#include <allegro5/allegro_direct3d.h>
 ~~~~
 
 ## API: al_get_d3d_device
diff --git a/docs/src/refman/display.txt b/docs/src/refman/display.txt
index eeb5515..8d790a8 100644
--- a/docs/src/refman/display.txt
+++ b/docs/src/refman/display.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 All drawing operations end up being visible on a display which is the same as
diff --git a/docs/src/refman/events.txt b/docs/src/refman/events.txt
index e65f9f8..b984ecd 100644
--- a/docs/src/refman/events.txt
+++ b/docs/src/refman/events.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 Events are generated by event sources. Most notably, each of the input
diff --git a/docs/src/refman/file.txt b/docs/src/refman/file.txt
index 24bc2e7..3cd7b3f 100644
--- a/docs/src/refman/file.txt
+++ b/docs/src/refman/file.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_FILE
diff --git a/docs/src/refman/fixed.txt b/docs/src/refman/fixed.txt
index aa42a81..ebe5ca1 100644
--- a/docs/src/refman/fixed.txt
+++ b/docs/src/refman/fixed.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: al_fixed
diff --git a/docs/src/refman/font.txt b/docs/src/refman/font.txt
index 511c7e7..6c85774 100644
--- a/docs/src/refman/font.txt
+++ b/docs/src/refman/font.txt
@@ -4,7 +4,7 @@ These functions are declared in the following header file.
 Link with allegro_font.
 
 ~~~~c
- #include <allegro5/allegro_font.h>
+#include <allegro5/allegro_font.h>
 ~~~~
 
 ## General font routines
diff --git a/docs/src/refman/fshook.txt b/docs/src/refman/fshook.txt
index ca837bd..649a877 100644
--- a/docs/src/refman/fshook.txt
+++ b/docs/src/refman/fshook.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 These functions allow access to the filesystem. This can either be the real
diff --git a/docs/src/refman/fullscreen_mode.txt b/docs/src/refman/fullscreen_mode.txt
index 9a0d7dd..2e6b1e6 100644
--- a/docs/src/refman/fullscreen_mode.txt
+++ b/docs/src/refman/fullscreen_mode.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_DISPLAY_MODE
diff --git a/docs/src/refman/graphics.txt b/docs/src/refman/graphics.txt
index 5922e03..dd3831e 100644
--- a/docs/src/refman/graphics.txt
+++ b/docs/src/refman/graphics.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## Colors
diff --git a/docs/src/refman/haptic.txt b/docs/src/refman/haptic.txt
index b182931..229dc4a 100644
--- a/docs/src/refman/haptic.txt
+++ b/docs/src/refman/haptic.txt
@@ -4,7 +4,7 @@ Haptic functions support force feedback and vibration on input devices.
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 Currently force feedback is fully supported on Linux and on Windows for 
diff --git a/docs/src/refman/image.txt b/docs/src/refman/image.txt
index f42050d..d563e54 100644
--- a/docs/src/refman/image.txt
+++ b/docs/src/refman/image.txt
@@ -4,7 +4,7 @@ These functions are declared in the following header file.
 Link with allegro_image.
 
 ~~~~c
- #include <allegro5/allegro_image.h>
+#include <allegro5/allegro_image.h>
 ~~~~
 
 ## API: al_init_image_addon
diff --git a/docs/src/refman/joystick.txt b/docs/src/refman/joystick.txt
index 2a0398a..ceb74b8 100644
--- a/docs/src/refman/joystick.txt
+++ b/docs/src/refman/joystick.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 On Windows there are two joystick drivers, a DirectInput one and an Xinput 
diff --git a/docs/src/refman/keyboard.txt b/docs/src/refman/keyboard.txt
index a24c8b1..b4a2875 100644
--- a/docs/src/refman/keyboard.txt
+++ b/docs/src/refman/keyboard.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_KEYBOARD_STATE
diff --git a/docs/src/refman/memfile.txt b/docs/src/refman/memfile.txt
index dc5f077..e7c5b17 100644
--- a/docs/src/refman/memfile.txt
+++ b/docs/src/refman/memfile.txt
@@ -7,7 +7,7 @@ These functions are declared in the following header file.
 Link with allegro_memfile.
 
 ~~~~c
- #include <allegro5/allegro_memfile.h>
+#include <allegro5/allegro_memfile.h>
 ~~~~
 
 ## API: al_open_memfile
diff --git a/docs/src/refman/memory.txt b/docs/src/refman/memory.txt
index bfc36bb..198874f 100644
--- a/docs/src/refman/memory.txt
+++ b/docs/src/refman/memory.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: al_malloc
diff --git a/docs/src/refman/misc.txt b/docs/src/refman/misc.txt
index 4bb6524..71f3322 100644
--- a/docs/src/refman/misc.txt
+++ b/docs/src/refman/misc.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_PI
diff --git a/docs/src/refman/monitor.txt b/docs/src/refman/monitor.txt
index 3cc9d9c..eb9e146 100644
--- a/docs/src/refman/monitor.txt
+++ b/docs/src/refman/monitor.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_MONITOR_INFO
diff --git a/docs/src/refman/mouse.txt b/docs/src/refman/mouse.txt
index 823d387..c6878cb 100644
--- a/docs/src/refman/mouse.txt
+++ b/docs/src/refman/mouse.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_MOUSE_STATE
diff --git a/docs/src/refman/native_dialog.txt b/docs/src/refman/native_dialog.txt
index 88b7ade..973dad4 100644
--- a/docs/src/refman/native_dialog.txt
+++ b/docs/src/refman/native_dialog.txt
@@ -4,7 +4,7 @@ These functions are declared in the following header file.
 Link with allegro_dialog.
 
 ~~~~c
- #include <allegro5/allegro_native_dialog.h>
+#include <allegro5/allegro_native_dialog.h>
 ~~~~
 
 ## API: ALLEGRO_FILECHOOSER
@@ -264,7 +264,7 @@ which item generated the event.
 A basic example:
 
 ~~~~c
- #define FILE_EXIT_ID 1
+#define FILE_EXIT_ID 1
 
 ALLEGRO_MENU *menu = al_create_menu();
 ALLEGRO_MENU *file_menu = al_create_menu();
diff --git a/docs/src/refman/opengl.txt b/docs/src/refman/opengl.txt
index 81acb22..40d8fbe 100644
--- a/docs/src/refman/opengl.txt
+++ b/docs/src/refman/opengl.txt
@@ -3,7 +3,7 @@
 These functions are declared in the following header file:
 
 ~~~~c
- #include <allegro5/allegro_opengl.h>
+#include <allegro5/allegro_opengl.h>
 ~~~~
 
 ## API: al_get_opengl_extension_list
diff --git a/docs/src/refman/path.txt b/docs/src/refman/path.txt
index 4c460c2..b20b177 100644
--- a/docs/src/refman/path.txt
+++ b/docs/src/refman/path.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 We define a path as an optional *drive*, followed by zero or more *directory
diff --git a/docs/src/refman/physfs.txt b/docs/src/refman/physfs.txt
index f8f678e..07334f2 100644
--- a/docs/src/refman/physfs.txt
+++ b/docs/src/refman/physfs.txt
@@ -17,7 +17,7 @@ These functions are declared in the following header file.
 Link with allegro_physfs.
 
 ~~~~c
- #include <allegro5/allegro_physfs.h>
+#include <allegro5/allegro_physfs.h>
 ~~~~
 
 ## API: al_set_physfs_file_interface
diff --git a/docs/src/refman/platform.txt b/docs/src/refman/platform.txt
index e15b417..fbb76a0 100644
--- a/docs/src/refman/platform.txt
+++ b/docs/src/refman/platform.txt
@@ -5,7 +5,7 @@
 These functions are declared in the following header file:
 
 ~~~~c
- #include <allegro5/allegro_windows.h>
+#include <allegro5/allegro_windows.h>
 ~~~~
 
 ### API: al_get_win_window_handle
@@ -43,7 +43,7 @@ Since: 5.1.2
 These functions are declared in the following header file:
 
 ~~~~c
- #include <allegro5/allegro_osx.h>
+#include <allegro5/allegro_osx.h>
 ~~~~
 
 ### API: al_osx_get_window
@@ -57,7 +57,7 @@ Since: 5.0.8, 5.1.3
 These functions are declared in the following header file:
 
 ~~~~c
- #include <allegro5/allegro_iphone.h>
+#include <allegro5/allegro_iphone.h>
 ~~~~
 
 ### API: al_iphone_set_statusbar_orientation
@@ -88,7 +88,7 @@ Since: 5.1.0
 These functions are declared in the following header file:
 
 ~~~~c
- #include <allegro5/allegro_android.h>
+#include <allegro5/allegro_android.h>
 ~~~~
 
 ### API: al_android_set_apk_file_interface
diff --git a/docs/src/refman/primitives.txt b/docs/src/refman/primitives.txt
index d84ceb0..5dc9428 100644
--- a/docs/src/refman/primitives.txt
+++ b/docs/src/refman/primitives.txt
@@ -4,7 +4,7 @@ These functions are declared in the following header file.
 Link with allegro_primitives.
 
 ~~~~c
- #include <allegro5/allegro_primitives.h>
+#include <allegro5/allegro_primitives.h>
 ~~~~
 
 ## General
diff --git a/docs/src/refman/shader.txt b/docs/src/refman/shader.txt
index fa24200..84a2dbf 100644
--- a/docs/src/refman/shader.txt
+++ b/docs/src/refman/shader.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_SHADER
diff --git a/docs/src/refman/state.txt b/docs/src/refman/state.txt
index 3c014e2..a4a0496 100644
--- a/docs/src/refman/state.txt
+++ b/docs/src/refman/state.txt
@@ -2,7 +2,9 @@
 
 These functions are declared in the main Allegro header file:
 
-     #include <allegro5/allegro.h>
+~~~~c
+#include <allegro5/allegro.h>
+~~~~
 
 ## API: ALLEGRO_STATE
 
diff --git a/docs/src/refman/system.txt b/docs/src/refman/system.txt
index 88ce75d..b6670a7 100644
--- a/docs/src/refman/system.txt
+++ b/docs/src/refman/system.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: al_install_system
diff --git a/docs/src/refman/threads.txt b/docs/src/refman/threads.txt
index 5f5b1f4..8609d6c 100644
--- a/docs/src/refman/threads.txt
+++ b/docs/src/refman/threads.txt
@@ -11,7 +11,7 @@ semantics and avoid edge cases.
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 
diff --git a/docs/src/refman/time.txt b/docs/src/refman/time.txt
index 47dcae8..68976ae 100644
--- a/docs/src/refman/time.txt
+++ b/docs/src/refman/time.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_TIMEOUT
diff --git a/docs/src/refman/timer.txt b/docs/src/refman/timer.txt
index 2f50cc6..df21646 100644
--- a/docs/src/refman/timer.txt
+++ b/docs/src/refman/timer.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_TIMER
diff --git a/docs/src/refman/touch.txt b/docs/src/refman/touch.txt
index 011aa57..fe3e36d 100644
--- a/docs/src/refman/touch.txt
+++ b/docs/src/refman/touch.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## API: ALLEGRO_TOUCH_INPUT
diff --git a/docs/src/refman/transformations.txt b/docs/src/refman/transformations.txt
index e996cb0..27f0d41 100644
--- a/docs/src/refman/transformations.txt
+++ b/docs/src/refman/transformations.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 Transformations allow you to transform the coordinates you use for drawing
diff --git a/docs/src/refman/utf8.txt b/docs/src/refman/utf8.txt
index b600f02..02e79b3 100644
--- a/docs/src/refman/utf8.txt
+++ b/docs/src/refman/utf8.txt
@@ -3,7 +3,7 @@
 These functions are declared in the main Allegro header file:
 
 ~~~~c
- #include <allegro5/allegro.h>
+#include <allegro5/allegro.h>
 ~~~~
 
 ## About UTF-8 string routines
diff --git a/docs/src/refman/video.txt b/docs/src/refman/video.txt
index 7d0c54c..b175ee9 100644
--- a/docs/src/refman/video.txt
+++ b/docs/src/refman/video.txt
@@ -4,7 +4,7 @@ These functions are declared in the following header file.
 Link with allegro_video.
 
 ~~~~c
- #include <allegro5/allegro_video.h>
+#include <allegro5/allegro_video.h>
 ~~~~
 
 Currently we have an ffmpeg backend and a Ogg backend (Theora + Vorbis).
-- 
1.9.1


--------------020504010202040802090609--




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/