hmml_to_html.c: Sanitise the refs menu [#15]

Also update hmmlib.h for the new marker parameter
This commit is contained in:
Matt Mascarenhas 2017-03-19 01:23:44 +00:00
parent c31b486cfa
commit 678dc869c5
4 changed files with 58 additions and 5 deletions

Binary file not shown.

View File

@ -23,6 +23,12 @@ typedef struct
int Size; int Size;
} buffer; } buffer;
typedef struct
{
char *Source;
char *RefTitle;
} ref_info;
void void
ClaimBuffer(char *MemoryArena, int *ClaimedMemory, buffer *Buffer, int Size) ClaimBuffer(char *MemoryArena, int *ClaimedMemory, buffer *Buffer, int Size)
{ {
@ -32,6 +38,30 @@ ClaimBuffer(char *MemoryArena, int *ClaimedMemory, buffer *Buffer, int Size)
Buffer->Ptr = Buffer->Location; Buffer->Ptr = Buffer->Location;
} }
ref_info
ParseRef(HMML_Reference RefInput)
{
ref_info Info;
if(RefInput.author)
{
Info.Source = RefInput.author;
Info.RefTitle = RefInput.title;
return Info;
}
else if(RefInput.page)
{
Info.Source = RefInput.site;
Info.RefTitle = RefInput.page;
return Info;
}
else
{
Info.Source = "";
Info.RefTitle = RefInput.site;
return Info;
}
}
int int
TimecodeToSeconds(char *Timecode) TimecodeToSeconds(char *Timecode)
{ {
@ -207,6 +237,7 @@ main(int ArgC, char **Args)
{ {
for(int i = 0; i < HMML.annotations[AnnotationIndex].reference_count; ++i) for(int i = 0; i < HMML.annotations[AnnotationIndex].reference_count; ++i)
{ {
HMML_Reference *CurrentRef = HMML.annotations[AnnotationIndex].references + i;
// NOTE(matt): Consider removing the ref_index class if it ain't needed // NOTE(matt): Consider removing the ref_index class if it ain't needed
sprintf(Working.Location, sprintf(Working.Location,
" <a data-id=\"%d\" href=\"%s\" target=\"_blank\" class=\"ref\">\n" " <a data-id=\"%d\" href=\"%s\" target=\"_blank\" class=\"ref\">\n"
@ -222,9 +253,9 @@ main(int ArgC, char **Args)
" </div>\n" " </div>\n"
" </a>\n", " </a>\n",
AnnotationIndex, AnnotationIndex,
HMML.annotations[AnnotationIndex].references[i].url, CurrentRef->url,
HMML.annotations[AnnotationIndex].references[i].site ? HMML.annotations[AnnotationIndex].references[i].site : HMML.annotations[AnnotationIndex].references[i].author, ParseRef(*CurrentRef).Source,
HMML.annotations[AnnotationIndex].references[i].page ? HMML.annotations[AnnotationIndex].references[i].page : HMML.annotations[AnnotationIndex].references[i].title, ParseRef(*CurrentRef).RefTitle,
TimecodeToSeconds(HMML.annotations[AnnotationIndex].time), TimecodeToSeconds(HMML.annotations[AnnotationIndex].time),
ReferenceIndex, ReferenceIndex,
HMML.annotations[AnnotationIndex].time); HMML.annotations[AnnotationIndex].time);
@ -275,7 +306,7 @@ HMML.annotations[AnnotationIndex].time);
{ {
for(int MarkerIndex = 0; MarkerIndex < HMML.annotations[AnnotationIndex].marker_count; ++MarkerIndex) for(int MarkerIndex = 0; MarkerIndex < HMML.annotations[AnnotationIndex].marker_count; ++MarkerIndex)
{ {
if(!StringsDiffer("blackboard", HMML.annotations[AnnotationIndex].markers[MarkerIndex].text) && if(!StringsDiffer("blackboard", HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker) &&
HMML.annotations[AnnotationIndex].markers[MarkerIndex].type == HMML_CATEGORY) HMML.annotations[AnnotationIndex].markers[MarkerIndex].type == HMML_CATEGORY)
{ {
sprintf(Working.Location, " blackboard"); sprintf(Working.Location, " blackboard");

View File

@ -40,7 +40,8 @@ typedef enum {
typedef struct { typedef struct {
HMML_MarkerType type; HMML_MarkerType type;
char* text; char* marker;
char* parameter;
int offset; int offset;
} HMML_Marker; } HMML_Marker;

View File

@ -84,6 +84,27 @@
font-style: oblique; font-style: oblique;
} }
.marker .content .categories {
display: inline-block;
}
.marker .content .categories .category {
border: 1px;
border-radius: 50%;
height: 6px;
width: 6px;
}
.category.memory {
border-color: #3399FF;
background: #3399FF;
}
.category.hardware {
border-color: #FF3333;
background: #FF3333;
}
/* MANDATORY */ /* MANDATORY */
.player_container { .player_container {