hmml_to_html.c: Coloured authors [#3]
This commit is contained in:
		
							parent
							
								
									f7181c1877
								
							
						
					
					
						commit
						f4217d5057
					
				|  | @ -97,6 +97,41 @@ StringsDiffer(char *A, char *B) | ||||||
|     return *A - *B; |     return *A - *B; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | int | ||||||
|  | CharToColour(char Char) | ||||||
|  | { | ||||||
|  |     if(Char >= 'a' && Char <= 'z') | ||||||
|  |     { | ||||||
|  |         return (((float)Char - 'a') / ('z' - 'a') * 0xFFFFFF); | ||||||
|  |     } | ||||||
|  |     else if(Char >= 'A' && Char <= 'Z') | ||||||
|  |     { | ||||||
|  |         return (((float)Char - 'A') / ('Z' - 'A') * 0xFFFFFF); | ||||||
|  |     } | ||||||
|  |     else if(Char >= '0' && Char <= '9') | ||||||
|  |     { | ||||||
|  |         return (((float)Char - '0') / ('9' - '0') * 0xFFFFFF); | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  |         return 0x777777; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int | ||||||
|  | StringToColourHash(char *String) | ||||||
|  | { | ||||||
|  |     int Result = 0; | ||||||
|  | 
 | ||||||
|  |     int i; | ||||||
|  |     for(i = 0; String[i]; ++i) | ||||||
|  |     { | ||||||
|  |         Result += CharToColour(String[i]); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     return Result / i; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| int | int | ||||||
| main(int ArgC, char **Args) | main(int ArgC, char **Args) | ||||||
| { | { | ||||||
|  | @ -139,7 +174,7 @@ main(int ArgC, char **Args) | ||||||
|          |          | ||||||
|         if(HMML.well_formed) |         if(HMML.well_formed) | ||||||
|         { |         { | ||||||
|             ClaimBuffer(MemoryArena, &ClaimedMemory, &Working, 1024); |             ClaimBuffer(MemoryArena, &ClaimedMemory, &Working, 1024 * 4); | ||||||
| 
 | 
 | ||||||
|             sprintf(Working.Location, |             sprintf(Working.Location, | ||||||
| "<html>\n" | "<html>\n" | ||||||
|  | @ -223,6 +258,19 @@ HMML.annotations[AnnotationIndex].time); | ||||||
| "                <div class=\"marker"); | "                <div class=\"marker"); | ||||||
|                 CopyBuffer(&Working, &Out); |                 CopyBuffer(&Working, &Out); | ||||||
| 
 | 
 | ||||||
|  |                 ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 1024); | ||||||
|  |                 int Inc = 0; | ||||||
|  | 
 | ||||||
|  |                 if(HMML.annotations[AnnotationIndex].author) | ||||||
|  |                 { | ||||||
|  |                     sprintf(Working.Location, " authored"); | ||||||
|  |                     CopyBuffer(&Working, &Out); | ||||||
|  | 
 | ||||||
|  |                     Inc = sprintf(Text.Ptr, "<span class=\"author\" style=\"color: #%X;\">%s</span> ", | ||||||
|  |                             StringToColourHash(HMML.annotations[AnnotationIndex].author), HMML.annotations[AnnotationIndex].author); | ||||||
|  |                     Text.Ptr += Inc; | ||||||
|  |                 } | ||||||
|  | 
 | ||||||
|                 if(HMML.annotations[AnnotationIndex].marker_count) |                 if(HMML.annotations[AnnotationIndex].marker_count) | ||||||
|                 { |                 { | ||||||
|                     for(int MarkerIndex = 0; MarkerIndex < HMML.annotations[AnnotationIndex].marker_count; ++MarkerIndex) |                     for(int MarkerIndex = 0; MarkerIndex < HMML.annotations[AnnotationIndex].marker_count; ++MarkerIndex) | ||||||
|  | @ -241,8 +289,6 @@ HMML.annotations[AnnotationIndex].time); | ||||||
| 
 | 
 | ||||||
|                 InPtr = HMML.annotations[AnnotationIndex].text; |                 InPtr = HMML.annotations[AnnotationIndex].text; | ||||||
| 
 | 
 | ||||||
|                 ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 256); |  | ||||||
| 
 |  | ||||||
|                 if(HMML.annotations[AnnotationIndex].reference_count) // || HMML.annotations[AnnotationIndex].is_quote)
 |                 if(HMML.annotations[AnnotationIndex].reference_count) // || HMML.annotations[AnnotationIndex].is_quote)
 | ||||||
|                 { |                 { | ||||||
|                     sprintf(Working.Location, " data-ref=\"%d\"", AnnotationIndex); |                     sprintf(Working.Location, " data-ref=\"%d\"", AnnotationIndex); | ||||||
|  | @ -255,7 +301,6 @@ HMML.annotations[AnnotationIndex].time); | ||||||
|                             *Text.Ptr++ = *InPtr++; |                             *Text.Ptr++ = *InPtr++; | ||||||
|                         } |                         } | ||||||
| 
 | 
 | ||||||
|                         int Inc = 0; |  | ||||||
|                         if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].offset <= 2) |                         if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].offset <= 2) | ||||||
|                         { |                         { | ||||||
|                             if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].page) |                             if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].page) | ||||||
|  | @ -291,7 +336,6 @@ HMML.annotations[AnnotationIndex].time); | ||||||
|                         Text.Ptr += Inc; |                         Text.Ptr += Inc; | ||||||
|                         ++DataRef; |                         ++DataRef; | ||||||
|                     } |                     } | ||||||
|                     CopyStringToBuffer(InPtr, &Text); |  | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 *Out.Ptr++ = '>'; |                 *Out.Ptr++ = '>'; | ||||||
|  |  | ||||||
|  | @ -44,20 +44,23 @@ | ||||||
| .marker:hover.blackboard  > .content { | .marker:hover.blackboard  > .content { | ||||||
|     background-color: #FFF8E7; |     background-color: #FFF8E7; | ||||||
|     background-size: 12px 12px; |     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); |     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 { | .marker:hover.blackboard .faded .content { | ||||||
|     background-color: rgba(42, 49, 114, 0.7); |     background-color: rgba(42, 49, 114, 0.7); | ||||||
|     background-size: 12px 12px; |     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); |     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; |     color: #FFFFFF; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .marker.blackboard > .content { | .marker.blackboard > .content { | ||||||
|     background-color: #FFFFFF; |     background-color: #FFFFFF; | ||||||
|     background-size: 12px 12px; |     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); |     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; |     color: black; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -68,10 +71,19 @@ | ||||||
| .marker.blackboard .progress .content { | .marker.blackboard .progress .content { | ||||||
|     background-color: #2A3172; |     background-color: #2A3172; | ||||||
|     background-size: 12px 12px; |     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); |     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; |     color: #FFFFFF; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | .marker.authored .content .author { | ||||||
|  |     font-style: normal; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .marker.authored { | ||||||
|  |     font-style: oblique; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* MANDATORY */ | /* MANDATORY */ | ||||||
| 
 | 
 | ||||||
| .player_container { | .player_container { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue