Text::Markdown::Discount
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.7 KiB

  1. /* block-level tags for passing html blocks through the blender
  2. */
  3. #include <stdio.h>
  4. #define __WITHOUT_AMALLOC 1
  5. #include "cstring.h"
  6. #include "tags.h"
  7. STRING(struct kw) blocktags;
  8. /* define a html block tag
  9. */
  10. static void
  11. define_one_tag(char *id, int selfclose)
  12. {
  13. struct kw *p = &EXPAND(blocktags);
  14. p->id = id;
  15. p->size = strlen(id);
  16. p->selfclose = selfclose;
  17. }
  18. /* case insensitive string sort (for qsort() and bsearch() of block tags)
  19. */
  20. static int
  21. casort(struct kw *a, struct kw *b)
  22. {
  23. if ( a->size != b->size )
  24. return a->size - b->size;
  25. return strncasecmp(a->id, b->id, b->size);
  26. }
  27. /* stupid cast to make gcc shut up about the function types being
  28. * passed into qsort() and bsearch()
  29. */
  30. typedef int (*stfu)(const void*,const void*);
  31. /* load in the standard collection of html tags that markdown supports
  32. */
  33. main()
  34. {
  35. int i;
  36. #define KW(x) define_one_tag(x, 0)
  37. #define SC(x) define_one_tag(x, 1)
  38. KW("STYLE");
  39. KW("SCRIPT");
  40. KW("ADDRESS");
  41. KW("BDO");
  42. KW("BLOCKQUOTE");
  43. KW("CENTER");
  44. KW("DFN");
  45. KW("DIV");
  46. KW("OBJECT");
  47. KW("H1");
  48. KW("H2");
  49. KW("H3");
  50. KW("H4");
  51. KW("H5");
  52. KW("H6");
  53. KW("LISTING");
  54. KW("NOBR");
  55. KW("UL");
  56. KW("P");
  57. KW("OL");
  58. KW("DL");
  59. KW("PLAINTEXT");
  60. KW("PRE");
  61. KW("TABLE");
  62. KW("WBR");
  63. KW("XMP");
  64. SC("HR");
  65. KW("IFRAME");
  66. KW("MAP");
  67. qsort(T(blocktags), S(blocktags), sizeof(struct kw), (stfu)casort);
  68. printf("static struct kw blocktags[] = {\n");
  69. for (i=0; i < S(blocktags); i++)
  70. printf(" { \"%s\", %d, %d },\n", T(blocktags)[i].id, T(blocktags)[i].size, T(blocktags)[i].selfclose );
  71. printf("};\n\n");
  72. printf("#define NR_blocktags %d\n", S(blocktags));
  73. exit(0);
  74. }