📄 html.c
字号:
case HTML_ACRONYM: case HTML_AU: case HTML_AUTHOR: case HTML_BIG: case HTML_CODE: case HTML_DFN: case HTML_KBD: case HTML_SAMP: case HTML_SMALL: case HTML_SUB: case HTML_SUP: case HTML_TT: case HTML_VAR: CHECK_ID(HTML_GEN_ID); break; /* ignore */ case HTML_DEL: case HTML_S: case HTML_STRIKE: CHECK_ID(HTML_GEN_ID); if (me->inUnderline == FALSE) HText_appendCharacter(me->text, LY_UNDERLINE_START_CHAR); HTML_put_string(me, "[DEL:"); if (me->inUnderline == FALSE) HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); HTML_put_character(me, ' '); me->in_word = NO; break; case HTML_INS: CHECK_ID(HTML_GEN_ID); if (me->inUnderline == FALSE) HText_appendCharacter(me->text, LY_UNDERLINE_START_CHAR); HTML_put_string(me, "[INS:"); if (me->inUnderline == FALSE) HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); HTML_put_character(me, ' '); me->in_word = NO; break; case HTML_Q: CHECK_ID(HTML_GEN_ID); /* * Should check LANG and/or DIR attributes, and the * me->node_anchor->charset and/or yet to be added * structure elements, to determine whether we should * use chevrons, but for now we'll always use double- * or single-quotes. - FM */ if (!(me->Quote_Level & 1)) HTML_put_character(me, '"'); else HTML_put_character(me, '`'); me->Quote_Level++; break; case HTML_PRE: /* Formatted text */ /* ** Set our inPRE flag to FALSE so that a newline ** immediately following the PRE start tag will ** be ignored. HTML_put_character() will set it ** to TRUE when the first character within the ** PRE block is received. - FM */ me->inPRE = FALSE; case HTML_LISTING: /* Literal text */ case HTML_XMP: case HTML_PLAINTEXT: change_paragraph_style(me, styles[ElementNumber]); UPDATE_STYLE; CHECK_ID(HTML_GEN_ID); if (me->comment_end) HText_appendText(me->text, me->comment_end); break; case HTML_BLOCKQUOTE: case HTML_BQ: change_paragraph_style(me, styles[ElementNumber]); UPDATE_STYLE; if (me->sp->tag_number == ElementNumber) LYEnsureDoubleSpace(me); CHECK_ID(HTML_BQ_ID); break; case HTML_NOTE: change_paragraph_style(me, styles[ElementNumber]); UPDATE_STYLE; if (me->sp->tag_number == ElementNumber) LYEnsureDoubleSpace(me); CHECK_ID(HTML_NOTE_ID); { char *note = NULL; /* * Indicate the type of NOTE. */ if (present && present[HTML_NOTE_CLASS] && value[HTML_NOTE_CLASS] && (!strcasecomp(value[HTML_NOTE_CLASS], "CAUTION") || !strcasecomp(value[HTML_NOTE_CLASS], "WARNING"))) { StrAllocCopy(note, value[HTML_NOTE_CLASS]); for (i = 0; note[i] != '\0'; i++) note[i] = TOUPPER(note[i]); StrAllocCat(note, ":"); } else if (present && present[HTML_NOTE_ROLE] && value[HTML_NOTE_ROLE] && (!strcasecomp(value[HTML_NOTE_ROLE], "CAUTION") || !strcasecomp(value[HTML_NOTE_ROLE], "WARNING"))) { StrAllocCopy(note, value[HTML_NOTE_ROLE]); for (i = 0; note[i] != '\0'; i++) note[i] = TOUPPER(note[i]); StrAllocCat(note, ":"); } else { StrAllocCopy(note, "NOTE:"); } if (me->inUnderline == FALSE) HText_appendCharacter(me->text, LY_UNDERLINE_START_CHAR); HTML_put_string(me, note); if (me->inUnderline == FALSE) HText_appendCharacter(me->text, LY_UNDERLINE_END_CHAR); HTML_put_character(me, ' '); FREE(note); } me->inLABEL = TRUE; me->in_word = NO; me->inP = FALSE; break; case HTML_ADDRESS: change_paragraph_style(me, styles[ElementNumber]); UPDATE_STYLE; if (me->sp->tag_number == ElementNumber) LYEnsureDoubleSpace(me); CHECK_ID(HTML_ADDRESS_ID); break; case HTML_DL: me->List_Nesting_Level++; /* increment the List nesting level */ if (me->List_Nesting_Level <= 0) { change_paragraph_style(me, present && present[HTML_DL_COMPACT] ? styles[HTML_DLC] : styles[HTML_DL]); } else if (me->List_Nesting_Level >= 6) { change_paragraph_style(me, present && present[HTML_DL_COMPACT] ? styles[HTML_DLC6] : styles[HTML_DL6]); } else { change_paragraph_style(me, present && present[HTML_DL_COMPACT] ? styles[(HTML_DLC1 - 1) + me->List_Nesting_Level] : styles[(HTML_DL1 - 1) + me->List_Nesting_Level]); } UPDATE_STYLE; /* update to the new style */ CHECK_ID(HTML_DL_ID); break; case HTML_DLC: me->List_Nesting_Level++; /* increment the List nesting level */ if (me->List_Nesting_Level <= 0) { change_paragraph_style(me, styles[HTML_DLC]); } else if (me->List_Nesting_Level >= 6) { change_paragraph_style(me, styles[HTML_DLC6]); } else { change_paragraph_style(me, styles[(HTML_DLC1 - 1) + me->List_Nesting_Level]); } UPDATE_STYLE; /* update to the new style */ CHECK_ID(HTML_DL_ID); break; case HTML_DT: CHECK_ID(HTML_GEN_ID); if (!me->style_change) { HText_appendParagraph(me->text); me->in_word = NO; me->sp->style->alignment = HT_LEFT; } me->inP = FALSE; break; case HTML_DD: CHECK_ID(HTML_GEN_ID); HText_setLastChar(me->text, ' '); /* absorb white space */ if (!me->style_change) { if (HText_LastLineSize(me->text, FALSE)) { HText_appendCharacter(me->text, '\r'); } } else { UPDATE_STYLE; HText_appendCharacter(me->text, '\t'); } me->sp->style->alignment = HT_LEFT; me->in_word = NO; me->inP = FALSE; break; case HTML_OL: /* * Set the default TYPE. */ me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = '1'; /* * Check whether we have a starting sequence number, * or want to continue the numbering from a previous * OL in this nest. - FM */ if (present && (present[HTML_OL_SEQNUM] || present[HTML_OL_START])) { int seqnum; /* * Give preference to the valid HTML 3.0 SEQNUM attribute name * over the Netscape START attribute name (too bad the Netscape * developers didn't read the HTML 3.0 specs before re-inventing * the "wheel" as "we'll"). - FM */ if (present[HTML_OL_SEQNUM] && value[HTML_OL_SEQNUM] && *value[HTML_OL_SEQNUM]) { seqnum = atoi(value[HTML_OL_SEQNUM]); } else if (present[HTML_OL_START] && value[HTML_OL_START] && *value[HTML_OL_START]) { seqnum = atoi(value[HTML_OL_START]); } else { seqnum = 1; } /* * Don't allow negative numbers less than * or equal to our flags, or numbers less * than 1 if an Alphabetic or Roman TYPE. - FM */ if (present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) { if (*value[HTML_OL_TYPE] == 'A') { me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 'A'; if (seqnum < 1) seqnum = 1; } else if (*value[HTML_OL_TYPE] == 'a') { me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 'a'; if (seqnum < 1) seqnum = 1; } else if (*value[HTML_OL_TYPE] == 'I') { me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 'I'; if (seqnum < 1) seqnum = 1; } else if (*value[HTML_OL_TYPE] == 'i') { me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 'i'; if (seqnum < 1) seqnum = 1; } else { if (seqnum <= OL_VOID) seqnum = OL_VOID + 1; } } else if (seqnum <= OL_VOID) { seqnum = OL_VOID + 1; } me->OL_Counter[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = seqnum; } else if (present && present[HTML_OL_CONTINUE]) { me->OL_Counter[me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11] = OL_CONTINUE; } else { me->OL_Counter[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 1; if (present && present[HTML_OL_TYPE] && value[HTML_OL_TYPE]) { if (*value[HTML_OL_TYPE] == 'A') { me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 'A'; } else if (*value[HTML_OL_TYPE] == 'a') { me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 'a'; } else if (*value[HTML_OL_TYPE] == 'I') { me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 'I'; } else if (*value[HTML_OL_TYPE] == 'i') { me->OL_Type[(me->List_Nesting_Level < 11 ? me->List_Nesting_Level+1 : 11)] = 'i'; } } } me->List_Nesting_Level++; if (me->List_Nesting_Level <= 0) { change_paragraph_style(me, styles[ElementNumber]); } else if (me->List_Nesting_Level >= 6) { change_paragraph_style(me, styles[HTML_OL6]); } else { change_paragraph_style(me, styles[HTML_OL1 + me->List_Nesting_Level - 1]); } UPDATE_STYLE; /* update to the new style */ CHECK_ID(HTML_OL_ID); break; case HTML_UL: me->List_Nesting_Level++; if (me->List_Nesting_Level <= 0) { if (!(present && present[HTML_UL_PLAIN]) && !(present && present[HTML_UL_TYPE] && value[HTML_UL_TYPE] && 0==strcasecomp(value[HTML_UL_TYPE], "PLAIN"))) { change_paragraph_style(me, styles[ElementNumber]); } else { change_paragraph_style(me, styles[HTML_DIR]); ElementNumber = HTML_DIR; } } else if (me->List_Nesting_Level >= 6) { if (!(present && present[HTML_UL_PLAIN]) && !(present && present[HTML_UL_TYPE] && value[HTML_UL_TYPE] && 0==strcasecomp(value[HTML_UL_TYPE], "PLAIN"))) { change_paragraph_style(me, styles[HTML_OL6]); } else { change_paragraph_style(me, styles[HTML_MENU6]); ElementNumber = HTML_DIR; } } else { if (!(present && present[HTML_UL_PLAIN]) && !(present && present[HTML_UL_TYPE] && value[HTML_UL_TYPE] && 0==strcasecomp(value[HTML_UL_TYPE], "PLAIN"))) { change_paragraph_style(me, styles[HTML_OL1 + me->List_Nesting_Level - 1]); } else { change_paragraph_style(me, styles[HTML_MENU1 + me->List_Nesting_Level - 1]); ElementNumber = HTML_DIR; } } UPDATE_STYLE; /* update to the new style */ CHECK_ID(HTML_UL_ID); break; case HTML_MENU: case HTML_DIR: me->List_Nesting_Level++; if (me->List_Nesting_Level <= 0) { change_paragraph_style(me, styles[ElementNumber]); } else if (me->List_Nesting_Level >= 6) { change_paragraph_style(me, styles[HTML_MENU6]); } else { change_paragraph_style(me, styles[HTML_MENU1 + me->List_Nesting_Level - 1]); } UPDATE_STYLE; /* update to the new style */ CHECK_ID(HTML_UL_ID); break; case HTML_LH: UPDATE_STYLE; /* update to the new style */ HText_appendParagraph(me->text); CHECK_ID(HTML_GEN_ID); HTML_put_character(me, HT_NON_BREAK_SPACE); HText_setLastChar(me->text, ' '); me->in_word = NO; me->inP = FALSE; break; case HTML_LI: UPDATE_STYLE; /* update to the new style */ HText_appendParagraph(me->text); me->sp->style->alignment = HT_LEFT; CHECK_ID(HTML_LI_ID); if (me->sp[0].tag_number == HTML_OL) { char number_string[20]; int counter, seqnum; char seqtype; counter = me->List_Nesting_Level < 11 ? me->List_Nesting_Level : 11; if (present && present[HTML_LI_TYPE] && value[HTML_LI_TYPE]) { if (*value[HTML_LI_TYPE] == '1') { me->OL_Type[counter] = '1'; } else if (*value[HTML_LI_TYPE] == 'A') { me->OL_Type[counter] = 'A'; } else if (*value[HTML_LI_TYPE] == 'a') { me->OL_Type[counter] = 'a'; } else if (*value[HTML_LI_TYPE] == 'I') { me->OL_Type[counter] = 'I'; } else if (*value[HTML_LI_TYPE] == 'i') { me->OL_Type[counter] = 'i'; } } if (present && present[HTML_LI_VALUE] && ((value[HTML_LI_VALUE] != NULL) && (*value[HTML_LI_VALUE] != '\0')) && ((isdigit(*value[HTML_LI_VALUE])) || (*value[HTML_LI_VALUE] == '-' && isdigit(*(value[HTML_LI_VALUE] + 1))))) { seqnum = atoi(value[HTML_LI_VALUE]); if (seqnum <= OL_VOID) seqnum = OL_VOID + 1; seqtype = me->OL_Type[counter]; if (seqtype != '1' && seqnum < 1) seqnum = 1; me->OL_Counter[counter] = seqnum + 1; } else if (me->OL_Counter[counter] >= OL_VOID) { seqnum = me->OL_Counter[counter]++; seqtype = me->OL_Type[counter]; if (seqtype != '1' && seqnum < 1) { seqnum = 1; me->OL_Counter[counter] = seqnum + 1; } } else { seqnum = me->Last_OL_Count + 1; seqtype = me->Last_OL_Type; for (i = (counter - 1); i >= 0; i--) { if (me->OL_Counter[i] > OL_VOID) { seqnum = me->OL_Counter[i]++; seqtype = me->OL_Type[i]; i = 0; } } } if (seqtype == 'A') { sprintf(number_string, LYUppercaseA_OL_String(seqnum)); } else if (seqtype == 'a') { sprintf(number_string, LYLowercaseA_OL_String(seqnum)); } else if (seqtype == 'I') { sprintf(number_string, LYUppercaseI_OL_String(seqnum)); } else if (seqtype == 'i') { sprintf(number_string, LYLowercaseI_OL_String(seqnum)); } else { sprintf(number_string, "%2d.", seqnum); } me->Last_OL_Count = seqnum; me->Last_OL_Type = seqtype; /* * Hack, because there is no append string! */ for (i = 0; number_string[i] != '\0'; i++) if (number_string[i] == ' ') HTML_put_character(me, HT_NON_BREAK_SPACE); else HTML_put_character(me, number_string[i]); /* * Use HTML_put_character so that any oth
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -