diff --git a/hmml_to_html/hmml_to_html.c b/hmml_to_html/hmml_to_html.c index c155f94..f062d0b 100644 --- a/hmml_to_html/hmml_to_html.c +++ b/hmml_to_html/hmml_to_html.c @@ -196,13 +196,39 @@ SanitisePunctuation(char *String) char *CategoryMedium[] = { "blackboard", - "Blackboard", "research", - "Research", "run", - "Run", }; +void +BuildCategories(buffer *AnnotationClass, buffer *Category, int *MarkerIndex, bool *HasCategory, char *Marker) +{ + for(int i = 0; i < ArrayCount(CategoryMedium); ++i) + { + if(!StringsDiffer(CategoryMedium[i], Marker)) + { + CopyStringToBuffer(AnnotationClass, " %s", SanitisePunctuation(Marker)); + ++*MarkerIndex; + return; + } + } + if(*HasCategory == FALSE) + { + CopyStringToBuffer(Category, "
", + SanitisePunctuation(Marker)); + *HasCategory = TRUE; + } + else + { + CopyStringToBuffer(Category, "
", + SanitisePunctuation(Marker)); + } + CopyStringToBuffer(AnnotationClass, " cat_%s", + SanitisePunctuation(Marker)); + ++*MarkerIndex; + return; +} + int main(int ArgC, char **Args) { @@ -271,6 +297,7 @@ main(int ArgC, char **Args) { bool HasCategory = FALSE; ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationHeader, 256); + ClaimBuffer(MemoryArena, &ClaimedMemory, &Category, 256); ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationClass, 128); ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 1024 * 4); @@ -304,11 +331,12 @@ HMML.annotations[AnnotationIndex].author); if(HMML.annotations[AnnotationIndex].markers[MarkerIndex].type == HMML_MEMBER) { CopyStringToBuffer(&Text, -"%s", +"%.*s", HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker, StringToColourHash(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker), -Readable); - InPtr += StringLength(Readable); +StringLength(Readable), InPtr); + InPtr += StringLength(Readable); + ++MarkerIndex; } else if(HMML.annotations[AnnotationIndex].markers[MarkerIndex].type == HMML_PROJECT) { @@ -317,34 +345,13 @@ Readable); HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker, StringToColourHash(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker), Readable); - InPtr += StringLength(Readable); + InPtr += StringLength(Readable); + ++MarkerIndex; } else if(HMML.annotations[AnnotationIndex].markers[MarkerIndex].type == HMML_CATEGORY) { - for(int i = 0; i < ArrayCount(CategoryMedium); ++i) - { - if(!StringsDiffer(CategoryMedium[i], HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)) - { - CopyStringToBuffer(&AnnotationClass, " %s", SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)); - goto NextCategory; - } - } - if(!HasCategory) - { - ClaimBuffer(MemoryArena, &ClaimedMemory, &Category, 256); - CopyStringToBuffer(&Category, "
", - SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)); - HasCategory = TRUE; - } - else - { - CopyStringToBuffer(&Category, "
", - SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)); - } - CopyStringToBuffer(&AnnotationClass, " cat_%s", - SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)); + BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker); } -NextCategory: ++MarkerIndex; } if(RefIndex < HMML.annotations[AnnotationIndex].reference_count && @@ -361,29 +368,7 @@ NextCategory: ++MarkerIndex; while(MarkerIndex < HMML.annotations[AnnotationIndex].marker_count) { - for(int i = 0; i < ArrayCount(CategoryMedium); ++i) - { - if(!StringsDiffer(CategoryMedium[i], HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)) - { - CopyStringToBuffer(&AnnotationClass, " %s", SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)); - goto NextCategoryInNode; - } - } - if(!HasCategory) - { - ClaimBuffer(MemoryArena, &ClaimedMemory, &Category, 256); - CopyStringToBuffer(&Category, "
", - SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)); - HasCategory = TRUE; - } - else - { - CopyStringToBuffer(&Category, "
", - SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)); - } - CopyStringToBuffer(&AnnotationClass, " cat_%s", - SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker)); -NextCategoryInNode: ++MarkerIndex; + BuildCategories(&AnnotationClass, &Category, &MarkerIndex, &HasCategory, HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker); } CopyStringToBuffer(&AnnotationClass, "\""); @@ -430,6 +415,7 @@ HMML.annotations[AnnotationIndex].time); ClaimedMemory -= Text.Size; ClaimedMemory -= AnnotationHeader.Size; + ClaimedMemory -= Category.Size; ClaimedMemory -= AnnotationClass.Size; ClaimedMemory -= Annotation.Size; } diff --git a/hmml_to_html/reference.html b/hmml_to_html/reference.html index f5f11b6..636b0fd 100644 --- a/hmml_to_html/reference.html +++ b/hmml_to_html/reference.html @@ -63,13 +63,13 @@
-
-
1:00insofaras Some text referring to Zilarrezko about this thing1 regarding triangle intersections he saw in the milton forums2
+
+
1:00insofaras Some text referring to Zilarrezko about this thing1 regarding triangle intersections he saw in the milton forums2
-
1:00insofaras Some text referring to Zilarrezko about this thing1 regarding triangle intersections he saw in the milton forums2
+
1:00insofaras Some text referring to Zilarrezko about this thing1 regarding triangle intersections he saw in the milton forums2
-
1:00insofaras Some text referring to Zilarrezko about this thing1 regarding triangle intersections he saw in the milton forums2
+
1:00insofaras Some text referring to Zilarrezko about this thing1 regarding triangle intersections he saw in the milton forums2