Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Annotation-System
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Annotation-Pushers
Annotation-System
Commits
30df421b
Commit
30df421b
authored
Mar 25, 2017
by
Matt Mascarenhas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hmml_to_html.c: Category styling
Also upgrade hmml.a for lower-cased markers
parent
769c79b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
11 deletions
+148
-11
hmml_to_html/hmml.a
hmml_to_html/hmml.a
+0
-0
hmml_to_html/hmml_to_html.c
hmml_to_html/hmml_to_html.c
+148
-11
No files found.
hmml_to_html/hmml.a
View file @
30df421b
No preview for this file type
hmml_to_html/hmml_to_html.c
View file @
30df421b
#if 0
ctime -begin ${0%.*}.ctm
clang -g -Wall -Wno-unused-variable -fsanitize=address -std=c99 $0 -o ${0%.*} hmml.a
#gcc -g -Wall -Wno-unused-variable -fsanitize=address -std=c99 $0 -o ${0%.*} hmml.a
gcc -g -Wall -fsanitize=address -std=c99 $0 -o ${0%.*} hmml.a
ctime -end ${0%.*}.ctm
exit
#endif
...
...
@@ -28,6 +29,8 @@ typedef struct
char
*
RefTitle
;
}
ref_info
;
#define ArrayCount(A) sizeof(A)/sizeof(*(A))
void
ClaimBuffer
(
char
*
MemoryArena
,
int
*
ClaimedMemory
,
buffer
*
Buffer
,
int
Size
)
{
...
...
@@ -158,6 +161,48 @@ StringToColourHash(char *String)
return
Result
/
i
;
}
int
StringLength
(
char
*
String
)
{
int
i
=
0
;
while
(
String
[
i
])
{
++
i
;
}
return
i
;
}
char
*
SanitisePunctuation
(
char
*
String
)
{
char
*
Ptr
=
String
;
while
(
*
Ptr
)
{
if
(
*
Ptr
==
' '
)
{
*
Ptr
=
'_'
;
}
if
((
*
Ptr
<
'0'
||
*
Ptr
>
'9'
)
&&
(
*
Ptr
<
'a'
||
*
Ptr
>
'z'
)
&&
(
*
Ptr
<
'A'
||
*
Ptr
>
'Z'
))
{
*
Ptr
=
'-'
;
}
++
Ptr
;
}
return
String
;
}
char
*
CategoryMedium
[]
=
{
"blackboard"
,
"Blackboard"
,
"research"
,
"Research"
,
"run"
,
"Run"
,
};
int
main
(
int
ArgC
,
char
**
Args
)
{
...
...
@@ -224,6 +269,7 @@ main(int ArgC, char **Args)
for
(
int
AnnotationIndex
=
0
;
AnnotationIndex
<
HMML
.
annotation_count
;
++
AnnotationIndex
)
{
bool
HasCategory
=
FALSE
;
ClaimBuffer
(
MemoryArena
,
&
ClaimedMemory
,
&
AnnotationHeader
,
256
);
ClaimBuffer
(
MemoryArena
,
&
ClaimedMemory
,
&
AnnotationClass
,
128
);
ClaimBuffer
(
MemoryArena
,
&
ClaimedMemory
,
&
Text
,
1024
*
4
);
...
...
@@ -235,7 +281,6 @@ TimecodeToSeconds(HMML.annotations[AnnotationIndex].time));
CopyStringToBuffer
(
&
AnnotationClass
,
" class=
\"
marker"
);
#if 0
if
(
HMML
.
annotations
[
AnnotationIndex
].
author
)
{
CopyStringToBuffer
(
&
AnnotationClass
,
" authored"
);
...
...
@@ -244,18 +289,102 @@ TimecodeToSeconds(HMML.annotations[AnnotationIndex].time));
StringToColourHash
(
HMML
.
annotations
[
AnnotationIndex
].
author
),
HMML
.
annotations
[
AnnotationIndex
].
author
);
}
#endif
InPtr
=
HMML
.
annotations
[
AnnotationIndex
].
text
;
//TODO(matt): Replace this CopyStringToBuffer() with real stuff!
CopyStringToBuffer
(
&
Text
,
HMML
.
annotations
[
AnnotationIndex
].
text
);
int
MarkerIndex
=
0
,
RefIndex
=
0
;
while
(
*
InPtr
)
{
if
(
MarkerIndex
<
HMML
.
annotations
[
AnnotationIndex
].
marker_count
&&
InPtr
-
HMML
.
annotations
[
AnnotationIndex
].
text
==
HMML
.
annotations
[
AnnotationIndex
].
markers
[
MarkerIndex
].
offset
)
{
char
*
Readable
=
HMML
.
annotations
[
AnnotationIndex
].
markers
[
MarkerIndex
].
parameter
?
HMML
.
annotations
[
AnnotationIndex
].
markers
[
MarkerIndex
].
parameter
:
HMML
.
annotations
[
AnnotationIndex
].
markers
[
MarkerIndex
].
marker
;
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>"
,
HMML
.
annotations
[
AnnotationIndex
].
markers
[
MarkerIndex
].
marker
,
StringToColourHash
(
HMML
.
annotations
[
AnnotationIndex
].
markers
[
MarkerIndex
].
marker
),
Readable
);
InPtr
+=
StringLength
(
Readable
);
}
else
if
(
HMML
.
annotations
[
AnnotationIndex
].
markers
[
MarkerIndex
].
type
==
HMML_PROJECT
)
{
CopyStringToBuffer
(
&
Text
,
"<a href=
\"
https://%s.handmade.network/
\"
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
);
}
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
));
}
NextCategory:
++
MarkerIndex
;
}
if
(
RefIndex
<
HMML
.
annotations
[
AnnotationIndex
].
reference_count
&&
InPtr
-
HMML
.
annotations
[
AnnotationIndex
].
text
==
HMML
.
annotations
[
AnnotationIndex
].
references
[
RefIndex
].
offset
)
{
++
RefIndex
;
}
if
(
*
InPtr
)
{
*
Text
.
Ptr
++
=
*
InPtr
++
;
}
}
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
;
}
CopyStringToBuffer
(
&
AnnotationClass
,
"
\"
"
);
CopyBuffer
(
&
AnnotationClass
,
&
AnnotationHeader
);
...
...
@@ -268,6 +397,14 @@ HMML.annotations[AnnotationIndex].author);
" <div class=
\"
content
\"
><span class=
\"
timecode
\"
>%s</span>"
,
HMML
.
annotations
[
AnnotationIndex
].
time
);
if
(
HasCategory
)
{
CopyStringToBuffer
(
&
Category
,
"</span>"
);
CopyBuffer
(
&
Category
,
&
Text
);
}
*
Text
.
Ptr
=
'\0'
;
CopyBuffer
(
&
Text
,
&
Annotation
);
CopyStringToBuffer
(
&
Annotation
,
"</div>
\n
"
...
...
@@ -309,7 +446,7 @@ HMML.annotations[AnnotationIndex].time);
ClaimBuffer
(
MemoryArena
,
&
ClaimedMemory
,
&
Master
,
1024
*
512
);
CopyStringToBuffer
(
&
Master
,
"<
!DOCTYPE
html>
\n
"
"<html>
\n
"
" <head>
\n
"
" <meta charset=
\"
UTF-8
\"
>
\n
"
"
\n
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment