hmml_to_html.c: Introduce BuildCatgories()

Also update reference.html with :research as a CategoryMedium
This commit is contained in:
Matt Mascarenhas 2017-03-25 03:10:15 +00:00
parent 30df421b9e
commit b32fd1e066
2 changed files with 43 additions and 57 deletions

View File

@ -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, "<span class=\"categories\"><div class=\"category %s\"></div>",
SanitisePunctuation(Marker));
*HasCategory = TRUE;
}
else
{
CopyStringToBuffer(Category, "<div class=\"category %s\"></div>",
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,
"<a href=\"https://handmade.network/m/%s\" target=\"blank\" style=\"color: #%X; text-decoration: none\">%s</a>",
"<a href=\"https://handmade.network/m/%s\" target=\"blank\" style=\"color: #%X; text-decoration: none\">%.*s</a>",
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, "<span class=\"categories\"><div class=\"category %s\"></div>",
SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker));
HasCategory = TRUE;
}
else
{
CopyStringToBuffer(&Category, "<div class=\"category %s\"></div>",
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, "<span class=\"categories\"><div class=\"category %s\"></div>",
SanitisePunctuation(HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker));
HasCategory = TRUE;
}
else
{
CopyStringToBuffer(&Category, "<div class=\"category %s\"></div>",
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;
}

View File

@ -63,13 +63,13 @@
<div class="player_container">
<div class="video_container" data-videoId="ug5WkCROkOk"></div>
<div class="markers_container">
<div class="marker authored cat_rendering cat_research" data-timestamp="60" data-ref="0,1">
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/Zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div><div class="category research"></div></span></div>
<div class="marker authored cat_rendering research" data-timestamp="60" data-ref="0,1">
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/Zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div></span></div>
<div class="progress faded">
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/Zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div><div class="category research"></div></span></div>
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/Zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div></span></div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/Zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div><div class="category research"></div></span></div>
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/Zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div></span></div>
</div>
</div>
<div class="marker" data-timestamp="176" data-ref="a">