aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-12-01 00:55:47 +0100
committerdec05eba <dec05eba@protonmail.com>2019-12-01 00:55:47 +0100
commit52528ca5980b5e8fe863ceee67067ac188c55a7a (patch)
tree4659f878f17b87caa8cfa34fe948434f456c9eb5 /src
parente300ab60cdd650563f81ce33af58f8f44048d91c (diff)
Do not wrap text in image board
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Fourchan.cpp39
-rw-r--r--src/plugins/Plugin.cpp3
2 files changed, 22 insertions, 20 deletions
diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp
index 58a0a57..11fd3ca 100644
--- a/src/plugins/Fourchan.cpp
+++ b/src/plugins/Fourchan.cpp
@@ -358,7 +358,7 @@ namespace QuickMedia {
TEXT,
QUOTE, // >
QUOTELINK, // >>POSTNO,
- LINEBREAK
+ LINE_CONTINUE
};
DataView text; // Set when type is TEXT, QUOTE or QUOTELINK
@@ -385,8 +385,14 @@ namespace QuickMedia {
using CommentPieceCallback = std::function<void(const CommentPiece&)>;
static void extract_comment_pieces(TidyDoc doc, TidyNode node, CommentPieceCallback callback) {
for(TidyNode child = tidyGetChild(node); child; child = tidyGetNext(child)) {
- //extract_comment_pieces(doc, child, callback);
const char *node_name = tidyNodeGetName(child);
+ if(node_name && strcmp(node_name, "wbr") == 0) {
+ CommentPiece comment_piece;
+ comment_piece.type = CommentPiece::Type::LINE_CONTINUE;
+ comment_piece.text = { (char*)"", 0 };
+ callback(comment_piece);
+ continue;
+ }
TidyNodeType node_type = tidyNodeGetType(child);
if(node_type == TidyNode_Start && node_name) {
TidyNode text_node = tidyGetChild(child);
@@ -412,12 +418,6 @@ namespace QuickMedia {
comment_piece.quote_postnumber = strtoll(a_href + 2, nullptr, 10);
}
}
- /*
- for(size_t i = 0; i < comment_piece.text.size; ++i) {
- if(comment_piece.text.data[i] == '\n')
- comment_piece.text.data[i] = ' ';
- }
- */
callback(comment_piece);
}
tidyBufFree(&tidy_buffer);
@@ -429,12 +429,6 @@ namespace QuickMedia {
CommentPiece comment_piece;
comment_piece.type = CommentPiece::Type::TEXT;
comment_piece.text = { (char*)tidy_buffer.bp, tidy_buffer.size };
- /*
- for(size_t i = 0; i < comment_piece.text.size; ++i) {
- if(comment_piece.text.data[i] == '\n')
- comment_piece.text.data[i] = ' ';
- }
- */
callback(comment_piece);
}
tidyBufFree(&tidy_buffer);
@@ -444,7 +438,8 @@ namespace QuickMedia {
static void extract_comment_pieces(const char *html_source, size_t size, CommentPieceCallback callback) {
TidyDoc doc = tidyCreate();
- tidyOptSetBool(doc, TidyShowWarnings, no);
+ for(int i = 0; i < N_TIDY_OPTIONS; ++i)
+ tidyOptSetBool(doc, (TidyOptionId)i, no);
if(tidyParseString(doc, html_source) < 0) {
CommentPiece comment_piece;
comment_piece.type = CommentPiece::Type::TEXT;
@@ -509,9 +504,12 @@ namespace QuickMedia {
comment_text.append(cp.text.data, cp.text.size);
break;
}
- case CommentPiece::Type::LINEBREAK:
- // comment_text += '\n';
+ case CommentPiece::Type::LINE_CONTINUE: {
+ if(!comment_text.empty() && comment_text.back() == '\n') {
+ comment_text.pop_back();
+ }
break;
+ }
}
}
);
@@ -609,9 +607,12 @@ namespace QuickMedia {
}
break;
}
- case CommentPiece::Type::LINEBREAK:
- // comment_text += '\n';
+ case CommentPiece::Type::LINE_CONTINUE: {
+ if(!comment_text.empty() && comment_text.back() == '\n') {
+ comment_text.pop_back();
+ }
break;
+ }
}
}
);
diff --git a/src/plugins/Plugin.cpp b/src/plugins/Plugin.cpp
index d1490d5..7c31292 100644
--- a/src/plugins/Plugin.cpp
+++ b/src/plugins/Plugin.cpp
@@ -67,8 +67,9 @@ namespace QuickMedia {
}
void html_unescape_sequences(std::string &str) {
- const std::array<HtmlEscapeSequence, 5> escape_sequences = {
+ const std::array<HtmlEscapeSequence, 6> escape_sequences = {
HtmlEscapeSequence { "&quot;", "\"" },
+ HtmlEscapeSequence { "&#039;", "'" },
HtmlEscapeSequence { "&#39;", "'" },
HtmlEscapeSequence { "&lt;", "<" },
HtmlEscapeSequence { "&gt;", ">" },