hmml_to_html.c: Category styling [#3]
Also squash some bugs and perform clean-up
This commit is contained in:
parent
e973b8376d
commit
f7181c1877
|
@ -83,6 +83,20 @@ CopyStringToBuffer(char *Src, buffer *Dest)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
StringsDiffer(char *A, char *B)
|
||||
{
|
||||
while(*A && *B)
|
||||
{
|
||||
if(*A != *B)
|
||||
{
|
||||
return *A - *B;
|
||||
}
|
||||
++A, ++B;
|
||||
}
|
||||
return *A - *B;
|
||||
}
|
||||
|
||||
int
|
||||
main(int ArgC, char **Args)
|
||||
{
|
||||
|
@ -139,9 +153,6 @@ main(int ArgC, char **Args)
|
|||
" <body>\n"
|
||||
" <div class=\"title\">\n"
|
||||
" <span class=\"episode_name\">%s</span>\n", HMML.metadata.title);
|
||||
|
||||
Out.Ptr = Out.Location;
|
||||
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
int AnnotationIndex = 0;
|
||||
|
@ -151,11 +162,10 @@ main(int ArgC, char **Args)
|
|||
if(HMML.annotations[AnnotationIndex].reference_count)
|
||||
{
|
||||
sprintf(Working.Location,
|
||||
" <div class=\"refs_container\">\n"
|
||||
" <span>References ▼</span>\n"
|
||||
" <div class=\"mouse_catcher\"></div>\n"
|
||||
" <div class=\"refs\">\n");
|
||||
|
||||
" <div class=\"refs_container\">\n"
|
||||
" <span>References ▼</span>\n"
|
||||
" <div class=\"mouse_catcher\"></div>\n"
|
||||
" <div class=\"refs\">\n");
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
while(AnnotationIndex < HMML.annotation_count)
|
||||
|
@ -164,18 +174,18 @@ main(int ArgC, char **Args)
|
|||
{
|
||||
// NOTE(matt): Consider removing the ref_index class if it ain't needed
|
||||
sprintf(Working.Location,
|
||||
" <a data-id=\"%d\" href=\"%s\" target=\"_blank\" class=\"ref\">\n"
|
||||
" <span class=\"ref_content\">\n"
|
||||
" <div class=\"source\">%s</div>\n"
|
||||
" <div class=\"ref_title\">%s</div>\n"
|
||||
" </span>\n"
|
||||
// NOTE(matt): Fill the div class="ref_indices" with <= 3 span
|
||||
" <a data-id=\"%d\" href=\"%s\" target=\"_blank\" class=\"ref\">\n"
|
||||
" <span class=\"ref_content\">\n"
|
||||
" <div class=\"source\">%s</div>\n"
|
||||
" <div class=\"ref_title\">%s</div>\n"
|
||||
" </span>\n"
|
||||
// TODO(matt): Fill the div class="ref_indices" with <= 3 span
|
||||
// class="ref_index" and ensure to put these <=3 spans on the same line without
|
||||
// a space between them
|
||||
" <div class=\"ref_indices\">\n"
|
||||
" <span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">%s</span></span>\n"
|
||||
" </div>\n"
|
||||
" </a>\n",
|
||||
" <div class=\"ref_indices\">\n"
|
||||
" <span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">%s</span></span>\n"
|
||||
" </div>\n"
|
||||
" </a>\n",
|
||||
AnnotationIndex,
|
||||
HMML.annotations[AnnotationIndex].references[i].url,
|
||||
HMML.annotations[AnnotationIndex].references[i].site ? HMML.annotations[AnnotationIndex].references[i].site : HMML.annotations[AnnotationIndex].references[i].author,
|
||||
|
@ -183,39 +193,60 @@ HMML.annotations[AnnotationIndex].references[i].page ? HMML.annotations[Annotati
|
|||
TimecodeToSeconds(HMML.annotations[AnnotationIndex].time),
|
||||
ReferenceIndex,
|
||||
HMML.annotations[AnnotationIndex].time);
|
||||
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
++ReferenceIndex;
|
||||
}
|
||||
++AnnotationIndex;
|
||||
}
|
||||
sprintf(Working.Location,
|
||||
" </div>\n"
|
||||
" </div>\n");
|
||||
CopyBuffer(&Working, &Out);
|
||||
}
|
||||
++AnnotationIndex;
|
||||
}
|
||||
|
||||
sprintf(Working.Location,
|
||||
" </div>\n"
|
||||
" <span class=\"annotator_container\">Annotator: <span class=\"annotator\">%s</span></span>\n"
|
||||
" </div>\n"
|
||||
" <span class=\"annotator_container\">Annotator: <span class=\"annotator\">%s</span></span>\n"
|
||||
" </div>\n"
|
||||
" <div class=\"player_container\">\n"
|
||||
" <div class=\"video_container\" data-videoId=\"%s\"></div>\n"
|
||||
" <div class=\"player_container\">\n"
|
||||
" <div class=\"video_container\" data-videoId=\"%s\"></div>\n"
|
||||
" <div class=\"markers_container\">\n", HMML.metadata.annotator, HMML.metadata.id);
|
||||
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
int DataRef = 1;
|
||||
|
||||
for(int AnnotationIndex = 0; AnnotationIndex < HMML.annotation_count; ++AnnotationIndex)
|
||||
{
|
||||
sprintf(Working.Location,
|
||||
" <div class=\"marker");
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
if(HMML.annotations[AnnotationIndex].marker_count)
|
||||
{
|
||||
for(int MarkerIndex = 0; MarkerIndex < HMML.annotations[AnnotationIndex].marker_count; ++MarkerIndex)
|
||||
{
|
||||
if(!StringsDiffer("blackboard", HMML.annotations[AnnotationIndex].markers[MarkerIndex].text) &&
|
||||
HMML.annotations[AnnotationIndex].markers[MarkerIndex].type == HMML_CATEGORY)
|
||||
{
|
||||
sprintf(Working.Location, " blackboard");
|
||||
CopyBuffer(&Working, &Out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(Working.Location, "\" data-timestamp=\"%d\"", TimecodeToSeconds(HMML.annotations[AnnotationIndex].time));
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
InPtr = HMML.annotations[AnnotationIndex].text;
|
||||
|
||||
ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 256);
|
||||
|
||||
if(HMML.annotations[AnnotationIndex].reference_count) // || HMML.annotations[AnnotationIndex].is_quote)
|
||||
{
|
||||
sprintf(Working.Location,
|
||||
" <div class=\"marker\" data-timestamp=\"%d\" data-ref=\"%d\">\n", TimecodeToSeconds(HMML.annotations[AnnotationIndex].time), AnnotationIndex);
|
||||
sprintf(Working.Location, " data-ref=\"%d\"", AnnotationIndex);
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
for(int RefLocalIndex = 0; RefLocalIndex < HMML.annotations[AnnotationIndex].reference_count; ++RefLocalIndex)
|
||||
{
|
||||
|
@ -262,17 +293,12 @@ HMML.annotations[AnnotationIndex].time);
|
|||
}
|
||||
CopyStringToBuffer(InPtr, &Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(Working.Location,
|
||||
" <div class=\"marker\" data-timestamp=\"%d\">\n", TimecodeToSeconds(HMML.annotations[AnnotationIndex].time));
|
||||
CopyStringToBuffer(InPtr, &Text);
|
||||
}
|
||||
|
||||
*Out.Ptr++ = '>';
|
||||
*Out.Ptr++ = '\n';
|
||||
CopyStringToBuffer(InPtr, &Text);
|
||||
*Text.Ptr = '\0';
|
||||
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
sprintf(Working.Location,
|
||||
" <div class=\"content\"><span class=\"timecode\">%s</span>%s</div>\n"
|
||||
" <div class=\"progress faded\">\n"
|
||||
|
@ -288,10 +314,9 @@ HMML.annotations[AnnotationIndex].time);
|
|||
Text.Location,
|
||||
HMML.annotations[AnnotationIndex].time,
|
||||
Text.Location);
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
ClaimedMemory -= Text.Size;
|
||||
|
||||
CopyBuffer(&Working, &Out);
|
||||
}
|
||||
|
||||
sprintf(Working.Location,
|
||||
|
@ -364,11 +389,8 @@ HMML.annotations[AnnotationIndex].time);
|
|||
" </script>\n"
|
||||
" </body>\n"
|
||||
"</html>\n");
|
||||
|
||||
CopyBuffer(&Working, &Out);
|
||||
|
||||
hmml_free(&HMML);
|
||||
|
||||
FILE *OutFile;
|
||||
//char *OutFilename;
|
||||
//sprintf(OutFilename, "%s.html", Args[FileIndex]);
|
||||
|
@ -381,6 +403,11 @@ HMML.annotations[AnnotationIndex].time);
|
|||
fwrite(Out.Location, Out.Ptr - Out.Location, 1, OutFile);
|
||||
fclose(OutFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s:%d: %s\n", Args[FileIndex], HMML.error.line, HMML.error.message);
|
||||
}
|
||||
hmml_free(&HMML);
|
||||
}
|
||||
free(MemoryArena);
|
||||
}
|
||||
|
|
|
@ -9,70 +9,70 @@
|
|||
<body>
|
||||
<div class="title">
|
||||
<span class="episode_name">Studying the Machine Interrupt Registers</span>
|
||||
<div class="refs_container">
|
||||
<span>References ▼</span>
|
||||
<div class="mouse_catcher"></div>
|
||||
<div class="refs">
|
||||
<a data-id="3" href="https://github.com/ucb-bar/rocket/blob/master/src/main/scala/instructions.scala" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">GitHub</div>
|
||||
<div class="ref_title">instructions.scala</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="543" class="timecode"><span class="ref_index">[1]</span><span class="time">9:03</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="3" href="https://en.wikipedia.org/wiki/Register-transfer_level" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">Wikipedia</div>
|
||||
<div class="ref_title">Register-transfer level</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="543" class="timecode"><span class="ref_index">[2]</span><span class="time">9:03</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="4" href="https://forums.sifive.com/t/confusion-regarding-freedom-e-sdk-inline-asm/383" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">SiFive Forums</div>
|
||||
<div class="ref_title">Confusion Regarding Freedom E SDK inline asm</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="955" class="timecode"><span class="ref_index">[3]</span><span class="time">15:55</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="6" href="https://riscv.org/specifications" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">RISC-V</div>
|
||||
<div class="ref_title">User-Level ISA Specification v2.1</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="1344" class="timecode"><span class="ref_index">[4]</span><span class="time">22:24</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="8" href="http://ericw.ca/notes/a-tiny-guide-to-gcc-inline-assembly.html" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">ericw.</div>
|
||||
<div class="ref_title">A Tiny Guide to GCC Inline Assembly</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="1733" class="timecode"><span class="ref_index">[5]</span><span class="time">28:53</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="10" href="https://riscv.org/specifications/privileged-isa/" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">RISC-V</div>
|
||||
<div class="ref_title">Draft Privileged ISA Specification v1.9.1</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="2421" class="timecode"><span class="ref_index">[6]</span><span class="time">40:21</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<div class="refs_container">
|
||||
<span>References ▼</span>
|
||||
<div class="mouse_catcher"></div>
|
||||
<div class="refs">
|
||||
<a data-id="3" href="https://github.com/ucb-bar/rocket/blob/master/src/main/scala/instructions.scala" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">GitHub</div>
|
||||
<div class="ref_title">instructions.scala</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="543" class="timecode"><span class="ref_index">[1]</span><span class="time">9:03</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="3" href="https://en.wikipedia.org/wiki/Register-transfer_level" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">Wikipedia</div>
|
||||
<div class="ref_title">Register-transfer level</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="543" class="timecode"><span class="ref_index">[2]</span><span class="time">9:03</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="4" href="https://forums.sifive.com/t/confusion-regarding-freedom-e-sdk-inline-asm/383" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">SiFive Forums</div>
|
||||
<div class="ref_title">Confusion Regarding Freedom E SDK inline asm</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="955" class="timecode"><span class="ref_index">[3]</span><span class="time">15:55</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="6" href="https://riscv.org/specifications" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">RISC-V</div>
|
||||
<div class="ref_title">User-Level ISA Specification v2.1</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="1344" class="timecode"><span class="ref_index">[4]</span><span class="time">22:24</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="8" href="http://ericw.ca/notes/a-tiny-guide-to-gcc-inline-assembly.html" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">ericw.</div>
|
||||
<div class="ref_title">A Tiny Guide to GCC Inline Assembly</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="1733" class="timecode"><span class="ref_index">[5]</span><span class="time">28:53</span></span>
|
||||
</div>
|
||||
</a>
|
||||
<a data-id="10" href="https://riscv.org/specifications/privileged-isa/" target="_blank" class="ref">
|
||||
<span class="ref_content">
|
||||
<div class="source">RISC-V</div>
|
||||
<div class="ref_title">Draft Privileged ISA Specification v1.9.1</div>
|
||||
</span>
|
||||
<div class="ref_indices">
|
||||
<span data-timestamp="2421" class="timecode"><span class="ref_index">[6]</span><span class="time">40:21</span></span>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<span class="annotator_container">Annotator: <span class="annotator">Miblo</span></span>
|
||||
</div>
|
||||
<span class="annotator_container">Annotator: <span class="annotator">Miblo</span></span>
|
||||
</div>
|
||||
<div class="player_container">
|
||||
<div class="video_container" data-videoId="ug5WkCROkOk"></div>
|
||||
<div class="player_container">
|
||||
<div class="video_container" data-videoId="ug5WkCROkOk"></div>
|
||||
<div class="markers_container">
|
||||
<div class="marker" data-timestamp="6">
|
||||
<div class="content"><span class="timecode">0:06</span>Recap and set the stage for the day</div>
|
||||
|
@ -83,7 +83,7 @@
|
|||
<div class="content"><span class="timecode">0:06</span>Recap and set the stage for the day</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="marker" data-timestamp="51">
|
||||
<div class="marker blackboard" data-timestamp="51">
|
||||
<div class="content"><span class="timecode">0:51</span>Intuition on two's complement</div>
|
||||
<div class="progress faded">
|
||||
<div class="content"><span class="timecode">0:51</span>Intuition on two's complement</div>
|
||||
|
@ -92,7 +92,7 @@
|
|||
<div class="content"><span class="timecode">0:51</span>Intuition on two's complement</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="marker" data-timestamp="250">
|
||||
<div class="marker blackboard" data-timestamp="250">
|
||||
<div class="content"><span class="timecode">4:10</span>We are counting with zeroes</div>
|
||||
<div class="progress faded">
|
||||
<div class="content"><span class="timecode">4:10</span>We are counting with zeroes</div>
|
||||
|
@ -110,7 +110,7 @@
|
|||
<div class="content"><span class="timecode">9:03</span>Revisit instructions.scala<sup>1</sup> and research register-transfer level<sup>2</sup></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="marker" data-timestamp="955" data-ref="4">
|
||||
<div class="marker blackboard" data-timestamp="955" data-ref="4">
|
||||
<div class="content"><span class="timecode">15:55</span>Come to understand how to specify that rs1 represents an immediate or a register, thanks to the reply to the "Confusion Regarding Freedom E SDK inline asm" forum thread<sup>3</sup></div>
|
||||
<div class="progress faded">
|
||||
<div class="content"><span class="timecode">15:55</span>Come to understand how to specify that rs1 represents an immediate or a register, thanks to the reply to the "Confusion Regarding Freedom E SDK inline asm" forum thread<sup>3</sup></div>
|
||||
|
@ -119,7 +119,7 @@
|
|||
<div class="content"><span class="timecode">15:55</span>Come to understand how to specify that rs1 represents an immediate or a register, thanks to the reply to the "Confusion Regarding Freedom E SDK inline asm" forum thread<sup>3</sup></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="marker" data-timestamp="1105">
|
||||
<div class="marker blackboard" data-timestamp="1105">
|
||||
<div class="content"><span class="timecode">18:25</span>Read clear_csr() to put csrrc into perspective with our new understanding of pseudo-instructions and the i vs r hints</div>
|
||||
<div class="progress faded">
|
||||
<div class="content"><span class="timecode">18:25</span>Read clear_csr() to put csrrc into perspective with our new understanding of pseudo-instructions and the i vs r hints</div>
|
||||
|
@ -146,7 +146,7 @@
|
|||
<div class="content"><span class="timecode">23:05</span>Walk through clear_csr() again</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="marker" data-timestamp="1733" data-ref="8">
|
||||
<div class="marker blackboard" data-timestamp="1733" data-ref="8">
|
||||
<div class="content"><span class="timecode">28:53</span>GNU Assembly Syntax: Constraints and Syntax<sup>5</sup></div>
|
||||
<div class="progress faded">
|
||||
<div class="content"><span class="timecode">28:53</span>GNU Assembly Syntax: Constraints and Syntax<sup>5</sup></div>
|
||||
|
|
|
@ -40,6 +40,38 @@
|
|||
color: black;
|
||||
}
|
||||
|
||||
/* Blackboard */
|
||||
.marker:hover.blackboard > .content {
|
||||
background-color: #FFF8E7;
|
||||
background-size: 12px 12px;
|
||||
background-image: linear-gradient(to right, rgba(51, 153, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px);
|
||||
}
|
||||
|
||||
.marker:hover.blackboard .faded .content {
|
||||
background-color: rgba(42, 49, 114, 0.7);
|
||||
background-size: 12px 12px;
|
||||
background-image: linear-gradient(to right, rgba(0, 0, 0, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(0, 0, 0, .16) 1px, transparent 1px);
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.marker.blackboard > .content {
|
||||
background-color: #FFFFFF;
|
||||
background-size: 12px 12px;
|
||||
background-image: linear-gradient(to right, rgba(51, 153, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(51, 153, 255, .16) 1px, transparent 1px);
|
||||
color: black;
|
||||
}
|
||||
|
||||
.marker.blackboard.current > .content {
|
||||
color: #2A3172;
|
||||
}
|
||||
|
||||
.marker.blackboard .progress .content {
|
||||
background-color: #2A3172;
|
||||
background-size: 12px 12px;
|
||||
background-image: linear-gradient(to right, rgba(255, 255, 255, .16) 1px, transparent 1px), linear-gradient(to bottom, rgba(255, 255, 255, .16) 1px, transparent 1px);
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* MANDATORY */
|
||||
|
||||
.player_container {
|
||||
|
|
Loading…
Reference in New Issue