basic html special lookups seem to be working
This commit is contained in:
parent
0d037a7b36
commit
806a7c4188
@ -103,6 +103,16 @@ identifier [A-z][A-z0-9]*
|
||||
ECHOS(("</" + tag_stack.top() + ">").c_str());
|
||||
pop_tag();
|
||||
}
|
||||
\< {
|
||||
ECHO_CANDIDATE;
|
||||
tag_candidate = "";
|
||||
ECHOS("<");
|
||||
}
|
||||
\> {
|
||||
ECHO_CANDIDATE;
|
||||
tag_candidate = "";
|
||||
ECHOS(">");
|
||||
}
|
||||
.|{wsnl} {
|
||||
ECHO;
|
||||
}
|
||||
@ -213,13 +223,7 @@ identifier [A-z][A-z0-9]*
|
||||
|
||||
<*>{
|
||||
\\[(){},:;] {
|
||||
ECHOC(yytext[0]);
|
||||
}
|
||||
\\< {
|
||||
ECHOS("<");
|
||||
}
|
||||
\\> {
|
||||
ECHOS(">");
|
||||
ECHOC(yytext[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,241 +0,0 @@
|
||||
Á Á
|
||||
á á
|
||||
 Â
|
||||
â â
|
||||
´ ´
|
||||
Æ Æ
|
||||
æ æ
|
||||
À À
|
||||
à à
|
||||
Α Α
|
||||
α α
|
||||
& &
|
||||
∧ ∧
|
||||
∠ ∠
|
||||
' '
|
||||
Å Å
|
||||
å å
|
||||
≈ ≈
|
||||
à Ã
|
||||
ã ã
|
||||
Ä Ä
|
||||
ä ä
|
||||
„ „
|
||||
Β Β
|
||||
β β
|
||||
¦ ¦
|
||||
• •
|
||||
∩ ∩
|
||||
Ç Ç
|
||||
ç ç
|
||||
¸ ¸
|
||||
¢ ¢
|
||||
Χ Χ
|
||||
χ χ
|
||||
ˆ ˆ
|
||||
♣ ♣
|
||||
≅ ≅
|
||||
© ©
|
||||
↵ ↵
|
||||
∪ ∪
|
||||
¤ ¤
|
||||
† †
|
||||
‡ ‡
|
||||
↓ ↓
|
||||
° °
|
||||
Δ Δ
|
||||
δ δ
|
||||
♦ ♦
|
||||
÷ ÷
|
||||
É É
|
||||
é é
|
||||
Ê Ê
|
||||
ê ê
|
||||
È È
|
||||
è è
|
||||
∅ ∅
|
||||
   
|
||||
   
|
||||
Ε Ε
|
||||
ε ε
|
||||
≡ ≡
|
||||
Η Η
|
||||
η η
|
||||
Ð Ð
|
||||
ð ð
|
||||
Ë Ë
|
||||
ë ë
|
||||
€ €
|
||||
∃ ∃
|
||||
ƒ ƒ
|
||||
∀ ∀
|
||||
½ ½
|
||||
¼ ¼
|
||||
¾ ¾
|
||||
Γ Γ
|
||||
γ γ
|
||||
≥ ≥
|
||||
> >
|
||||
↔ ↔
|
||||
♥ ♥
|
||||
… …
|
||||
Í Í
|
||||
í í
|
||||
Î Î
|
||||
î î
|
||||
¡ ¡
|
||||
Ì Ì
|
||||
ì ì
|
||||
∞ ∞
|
||||
∫ ∫
|
||||
Ι Ι
|
||||
ι ι
|
||||
¿ ¿
|
||||
∈ ∈
|
||||
Ï Ï
|
||||
ï ï
|
||||
Κ Κ
|
||||
κ κ
|
||||
Λ Λ
|
||||
λ λ
|
||||
« «
|
||||
← ←
|
||||
⌈ ⌈
|
||||
“ “
|
||||
≤ ≤
|
||||
⌊ ⌊
|
||||
∗ ∗
|
||||
◊ ◊
|
||||
‎ ‎
|
||||
‹ ‹
|
||||
‘ ‘
|
||||
< <
|
||||
¯ ¯
|
||||
— —
|
||||
µ µ
|
||||
· ·
|
||||
− −
|
||||
Μ Μ
|
||||
μ μ
|
||||
∇ ∇
|
||||
 
|
||||
– –
|
||||
≠ ≠
|
||||
∋ ∋
|
||||
¬ ¬
|
||||
∉ ∉
|
||||
⊄ ⊄
|
||||
Ñ Ñ
|
||||
ñ ñ
|
||||
Ν Ν
|
||||
ν ν
|
||||
Ó Ó
|
||||
ó ó
|
||||
Ô Ô
|
||||
ô ô
|
||||
Œ Œ
|
||||
œ œ
|
||||
Ò Ò
|
||||
ò ò
|
||||
‾ ‾
|
||||
Ω Ω
|
||||
ω ω
|
||||
Ο Ο
|
||||
ο ο
|
||||
⊕ ⊕
|
||||
∨ ∨
|
||||
ª ª
|
||||
º º
|
||||
Ø Ø
|
||||
ø ø
|
||||
Õ Õ
|
||||
õ õ
|
||||
⊗ ⊗
|
||||
Ö Ö
|
||||
ö ö
|
||||
¶ ¶
|
||||
∂ ∂
|
||||
‰ ‰
|
||||
⊥ ⊥
|
||||
Φ Φ
|
||||
φ φ
|
||||
Π Π
|
||||
π π
|
||||
ϖ ϖ
|
||||
± ±
|
||||
£ £
|
||||
′ ′
|
||||
″ ″
|
||||
∏ ∏
|
||||
∝ ∝
|
||||
Ψ Ψ
|
||||
ψ ψ
|
||||
" "
|
||||
√ √
|
||||
» »
|
||||
→ →
|
||||
⌉ ⌉
|
||||
” ”
|
||||
® ®
|
||||
⌋ ⌋
|
||||
Ρ Ρ
|
||||
ρ ρ
|
||||
‏ ‏
|
||||
› ›
|
||||
’ ’
|
||||
‚ ‚
|
||||
Š Š
|
||||
š š
|
||||
⋅ ⋅
|
||||
§ §
|
||||
­ ­
|
||||
Σ Σ
|
||||
σ σ
|
||||
ς ς
|
||||
∼ ∼
|
||||
♠ ♠
|
||||
⊂ ⊂
|
||||
⊆ ⊆
|
||||
∑ ∑
|
||||
¹ ¹
|
||||
² ²
|
||||
³ ³
|
||||
⊃ ⊃
|
||||
⊇ ⊇
|
||||
ß ß
|
||||
Τ Τ
|
||||
τ τ
|
||||
∴ ∴
|
||||
Θ Θ
|
||||
θ θ
|
||||
ϑ ϑ
|
||||
   
|
||||
Þ Þ
|
||||
þ þ
|
||||
˜ ˜
|
||||
× ×
|
||||
™ ™
|
||||
Ú Ú
|
||||
ú ú
|
||||
↑ ↑
|
||||
Û Û
|
||||
û û
|
||||
Ù Ù
|
||||
ù ù
|
||||
¨ ¨
|
||||
ϒ ϒ
|
||||
Υ Υ
|
||||
υ υ
|
||||
Ü Ü
|
||||
ü ü
|
||||
Ξ Ξ
|
||||
ξ ξ
|
||||
Ý Ý
|
||||
ý ý
|
||||
¥ ¥
|
||||
ÿ ÿ
|
||||
Ÿ Ÿ
|
||||
Ζ Ζ
|
||||
ζ ζ
|
||||
‍ ‍
|
||||
‌ ‌
|
|
273
source/html_special.hpp
Normal file
273
source/html_special.hpp
Normal file
@ -0,0 +1,273 @@
|
||||
#ifndef HTML_SPECIAL_HPP
|
||||
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
|
||||
const char * html_special_table[][2] =
|
||||
{
|
||||
{"Á", "Á"},
|
||||
{"á", "á"},
|
||||
{"Â", "Â"},
|
||||
{"â", "â"},
|
||||
{"´", "´"},
|
||||
{"Æ", "Æ"},
|
||||
{"æ", "æ"},
|
||||
{"À", "À"},
|
||||
{"à", "à"},
|
||||
{"Α", "Α"},
|
||||
{"α", "α"},
|
||||
{"&", "&"},
|
||||
{"∧", "∧"},
|
||||
{"∠", "∠"},
|
||||
{"'", "'"},
|
||||
{"Å", "Å"},
|
||||
{"å", "å"},
|
||||
{"≈", "≈"},
|
||||
{"Ã", "Ã"},
|
||||
{"ã", "ã"},
|
||||
{"Ä", "Ä"},
|
||||
{"ä", "ä"},
|
||||
{"„", "„"},
|
||||
{"Β", "Β"},
|
||||
{"β", "β"},
|
||||
{"¦", "¦"},
|
||||
{"•", "•"},
|
||||
{"∩", "∩"},
|
||||
{"Ç", "Ç"},
|
||||
{"ç", "ç"},
|
||||
{"¸", "¸"},
|
||||
{"¢", "¢"},
|
||||
{"Χ", "Χ"},
|
||||
{"χ", "χ"},
|
||||
{"ˆ", "ˆ"},
|
||||
{"♣", "♣"},
|
||||
{"≅", "≅"},
|
||||
{"©", "©"},
|
||||
{"↵", "↵"},
|
||||
{"∪", "∪"},
|
||||
{"¤", "¤"},
|
||||
{"†", "†"},
|
||||
{"‡", "‡"},
|
||||
{"↓", "↓"},
|
||||
{"°", "°"},
|
||||
{"Δ", "Δ"},
|
||||
{"δ", "δ"},
|
||||
{"♦", "♦"},
|
||||
{"÷", "÷"},
|
||||
{"É", "É"},
|
||||
{"é", "é"},
|
||||
{"Ê", "Ê"},
|
||||
{"ê", "ê"},
|
||||
{"È", "È"},
|
||||
{"è", "è"},
|
||||
{"∅", "∅"},
|
||||
{" ", " "},
|
||||
{" ", " "},
|
||||
{"Ε", "Ε"},
|
||||
{"ε", "ε"},
|
||||
{"≡", "≡"},
|
||||
{"Η", "Η"},
|
||||
{"η", "η"},
|
||||
{"Ð", "Ð"},
|
||||
{"ð", "ð"},
|
||||
{"Ë", "Ë"},
|
||||
{"ë", "ë"},
|
||||
{"€", "€"},
|
||||
{"∃", "∃"},
|
||||
{"ƒ", "ƒ"},
|
||||
{"∀", "∀"},
|
||||
{"½", "½"},
|
||||
{"¼", "¼"},
|
||||
{"¾", "¾"},
|
||||
{"Γ", "Γ"},
|
||||
{"γ", "γ"},
|
||||
{"≥", "≥"},
|
||||
{">", ">"},
|
||||
{"↔", "↔"},
|
||||
{"♥", "♥"},
|
||||
{"…", "…"},
|
||||
{"Í", "Í"},
|
||||
{"í", "í"},
|
||||
{"Î", "Î"},
|
||||
{"î", "î"},
|
||||
{"¡", "¡"},
|
||||
{"Ì", "Ì"},
|
||||
{"ì", "ì"},
|
||||
{"∞", "∞"},
|
||||
{"∫", "∫"},
|
||||
{"Ι", "Ι"},
|
||||
{"ι", "ι"},
|
||||
{"¿", "¿"},
|
||||
{"∈", "∈"},
|
||||
{"Ï", "Ï"},
|
||||
{"ï", "ï"},
|
||||
{"Κ", "Κ"},
|
||||
{"κ", "κ"},
|
||||
{"Λ", "Λ"},
|
||||
{"λ", "λ"},
|
||||
{"«", "«"},
|
||||
{"←", "←"},
|
||||
{"⌈", "⌈"},
|
||||
{"“", "“"},
|
||||
{"≤", "≤"},
|
||||
{"⌊", "⌊"},
|
||||
{"∗", "∗"},
|
||||
{"◊", "◊"},
|
||||
{"‎", "‎"},
|
||||
{"‹", "‹"},
|
||||
{"‘", "‘"},
|
||||
{"<", "<"},
|
||||
{"¯", "¯"},
|
||||
{"—", "—"},
|
||||
{"µ", "µ"},
|
||||
{"·", "·"},
|
||||
{"−", "−"},
|
||||
{"Μ", "Μ"},
|
||||
{"μ", "μ"},
|
||||
{"∇", "∇"},
|
||||
{" ", " "},
|
||||
{"–", "–"},
|
||||
{"≠", "≠"},
|
||||
{"∋", "∋"},
|
||||
{"¬", "¬"},
|
||||
{"∉", "∉"},
|
||||
{"⊄", "⊄"},
|
||||
{"Ñ", "Ñ"},
|
||||
{"ñ", "ñ"},
|
||||
{"Ν", "Ν"},
|
||||
{"ν", "ν"},
|
||||
{"Ó", "Ó"},
|
||||
{"ó", "ó"},
|
||||
{"Ô", "Ô"},
|
||||
{"ô", "ô"},
|
||||
{"Œ", "Œ"},
|
||||
{"œ", "œ"},
|
||||
{"Ò", "Ò"},
|
||||
{"ò", "ò"},
|
||||
{"‾", "‾"},
|
||||
{"Ω", "Ω"},
|
||||
{"ω", "ω"},
|
||||
{"Ο", "Ο"},
|
||||
{"ο", "ο"},
|
||||
{"⊕", "⊕"},
|
||||
{"∨", "∨"},
|
||||
{"ª", "ª"},
|
||||
{"º", "º"},
|
||||
{"Ø", "Ø"},
|
||||
{"ø", "ø"},
|
||||
{"Õ", "Õ"},
|
||||
{"õ", "õ"},
|
||||
{"⊗", "⊗"},
|
||||
{"Ö", "Ö"},
|
||||
{"ö", "ö"},
|
||||
{"¶", "¶"},
|
||||
{"∂", "∂"},
|
||||
{"‰", "‰"},
|
||||
{"⊥", "⊥"},
|
||||
{"Φ", "Φ"},
|
||||
{"φ", "φ"},
|
||||
{"Π", "Π"},
|
||||
{"π", "π"},
|
||||
{"ϖ", "ϖ"},
|
||||
{"±", "±"},
|
||||
{"£", "£"},
|
||||
{"′", "′"},
|
||||
{"″", "″"},
|
||||
{"∏", "∏"},
|
||||
{"∝", "∝"},
|
||||
{"Ψ", "Ψ"},
|
||||
{"ψ", "ψ"},
|
||||
{""", """},
|
||||
{"√", "√"},
|
||||
{"»", "»"},
|
||||
{"→", "→"},
|
||||
{"⌉", "⌉"},
|
||||
{"”", "”"},
|
||||
{"®", "®"},
|
||||
{"⌋", "⌋"},
|
||||
{"Ρ", "Ρ"},
|
||||
{"ρ", "ρ"},
|
||||
{"‏", "‏"},
|
||||
{"›", "›"},
|
||||
{"’", "’"},
|
||||
{"‚", "‚"},
|
||||
{"Š", "Š"},
|
||||
{"š", "š"},
|
||||
{"⋅", "⋅"},
|
||||
{"§", "§"},
|
||||
{"­", "­"},
|
||||
{"Σ", "Σ"},
|
||||
{"σ", "σ"},
|
||||
{"ς", "ς"},
|
||||
{"∼", "∼"},
|
||||
{"♠", "♠"},
|
||||
{"⊂", "⊂"},
|
||||
{"⊆", "⊆"},
|
||||
{"∑", "∑"},
|
||||
{"¹", "¹"},
|
||||
{"²", "²"},
|
||||
{"³", "³"},
|
||||
{"⊃", "⊃"},
|
||||
{"⊇", "⊇"},
|
||||
{"ß", "ß"},
|
||||
{"Τ", "Τ"},
|
||||
{"τ", "τ"},
|
||||
{"∴", "∴"},
|
||||
{"Θ", "Θ"},
|
||||
{"θ", "θ"},
|
||||
{"ϑ", "ϑ"},
|
||||
{" ", " "},
|
||||
{"Þ", "Þ"},
|
||||
{"þ", "þ"},
|
||||
{"˜", "˜"},
|
||||
{"×", "×"},
|
||||
{"™", "™"},
|
||||
{"Ú", "Ú"},
|
||||
{"ú", "ú"},
|
||||
{"↑", "↑"},
|
||||
{"Û", "Û"},
|
||||
{"û", "û"},
|
||||
{"Ù", "Ù"},
|
||||
{"ù", "ù"},
|
||||
{"¨", "¨"},
|
||||
{"ϒ", "ϒ"},
|
||||
{"Υ", "Υ"},
|
||||
{"υ", "υ"},
|
||||
{"Ü", "Ü"},
|
||||
{"ü", "ü"},
|
||||
{"Ξ", "Ξ"},
|
||||
{"ξ", "ξ"},
|
||||
{"Ý", "Ý"},
|
||||
{"ý", "ý"},
|
||||
{"¥", "¥"},
|
||||
{"ÿ", "ÿ"},
|
||||
{"Ÿ", "Ÿ"},
|
||||
{"Ζ", "Ζ"},
|
||||
{"ζ", "ζ"},
|
||||
{"‍", "‍"},
|
||||
{"‌", "‌"},
|
||||
};
|
||||
|
||||
const size_t html_special_table_size = sizeof(html_special_table) / sizeof(html_special_table[0]);
|
||||
|
||||
const char * html_special_table_lookup(const char * const name) {
|
||||
// this should be a iterating-decreasing jump search
|
||||
for (int i = 0; i < html_special_table_size; i++) {
|
||||
if (!strcmp(name, html_special_table[i][0])) {
|
||||
return html_special_table[i][1];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char * html_special_to_utf8(const char * const special) {
|
||||
static std::string r(special);
|
||||
trim(r);
|
||||
uint32_t i(std::stoi(r));
|
||||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> conv1;
|
||||
r = conv1.to_bytes(i);
|
||||
return r.c_str();
|
||||
}
|
||||
|
||||
#define HTML_SPECIAL_HPP
|
||||
#endif
|
@ -7,11 +7,6 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
// uint32_t a(3084);
|
||||
// std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> conv1;
|
||||
// std::string u8str = conv1.to_bytes(a);
|
||||
// std::cout << "UTF-8 conversion produced " << u8str.size() << " bytes:\n";
|
||||
|
||||
#include "cli.hpp"
|
||||
#include "exit_values.hpp"
|
||||
|
||||
|
@ -4,7 +4,10 @@
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#define ECHOS(s) fwrite(s, strlen(s), sizeof(char), yyout)
|
||||
#define ECHOS(s) { \
|
||||
const char * const ss = s; \
|
||||
fwrite(ss, strlen(ss), sizeof(char), yyout); \
|
||||
} while (0)
|
||||
#define ECHOC(c) fputc(c, yyout)
|
||||
|
||||
extern std::vector<std::string> ignore_list;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "global.hpp"
|
||||
#include "html_special.hpp"
|
||||
|
||||
bool is_comment_multiline = false;
|
||||
unsigned long long comment_begining;
|
||||
@ -37,6 +38,12 @@ identifier [A-z][A-z0-9]*
|
||||
ECHOS("//");
|
||||
BEGIN COMMENT;
|
||||
}
|
||||
&[A-z]+; {
|
||||
ECHOS(html_special_to_utf8(html_special_table_lookup(yytext)));
|
||||
}
|
||||
&[0-9]+; {
|
||||
ECHOS(html_special_to_utf8(yytext));
|
||||
}
|
||||
.|\n {
|
||||
ECHO;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ html {
|
||||
body {
|
||||
hr;
|
||||
div (class: myclass) {
|
||||
lorem ipsum
|
||||
lorem > ipsum
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<hr/>
|
||||
<div class='myclass'>
|
||||
lorem ipsum
|
||||
lorem > ipsum
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user