Merge branch 'main' into develop

This commit is contained in:
tastytea 2019-07-21 15:59:15 +02:00
commit 7383a4fcab
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
6 changed files with 41 additions and 19 deletions

View File

@ -26,7 +26,7 @@ steps:
CXXFLAGS: -pipe -O2
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
- apt-get update -q
@ -51,7 +51,7 @@ steps:
CXXFLAGS: -pipe -O2
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
@ -79,7 +79,7 @@ steps:
CXXFLAGS: -pipe -O2
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- apt-get update -q
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
@ -107,7 +107,7 @@ steps:
CXXFLAGS: -pipe -O2
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
- apt-get update -q
@ -129,7 +129,7 @@ steps:
CXXFLAGS: -pipe -O2
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
- echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/stretch.list
@ -190,7 +190,7 @@ steps:
CXXFLAGS: -pipe -O2
commands:
- rm /etc/apt/apt.conf.d/docker-clean
- rm /var/cache/apt/archives/lock
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
- echo "APT::Default-Release \"stretch\";" >> /etc/apt/apt.conf.d/00default_release
- echo "deb http://deb.debian.org/debian sid main" >> /etc/apt/sources.list.d/sid.list
- apt-get update -q

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.2)
project(remwharead
VERSION 0.4.1
VERSION 0.4.3
LANGUAGES CXX
)

View File

@ -40,9 +40,9 @@ void Export::AsciiDoc::print() const
<< ":Author: remwharead " << global::version << endl
<< ":Date: "
<< timepoint_to_string(system_clock::now()) << endl
<< ":TOC: right" << endl
<< ":TOCLevels: 2" << endl
<< endl;
<< ":TOC: right\n"
<< ":TOCLevels: 2\n"
<< ":!webfonts:\n\n";
tagmap alltags;
string day;
@ -57,7 +57,7 @@ void Export::AsciiDoc::print() const
}
_out << "[[dt_" << timepoint_to_string(entry.datetime) << "]]\n";
_out << "* link:" << entry.uri;
_out << "* link:" << replace_in_uri(entry.uri);
if (!entry.title.empty())
{
_out << '[' << replace_in_title(entry.title) << ']';
@ -71,7 +71,8 @@ void Export::AsciiDoc::print() const
_out << '_' << get_time(entry).substr(0, 5) << '_';
if (!entry.archive_uri.empty())
{
_out << " (link:" << entry.archive_uri << "[archived version])";
_out << " (link:" << replace_in_uri(entry.archive_uri)
<< "[archived version])";
}
bool separator = false;
@ -146,6 +147,9 @@ const string Export::AsciiDoc::replace_in_tag(const string &text) const
{ "&", "-" }, { "/", "-" },
{ "=", "-" }, { "^", "-" },
{ "!", "-" }, { "?", "-" },
{ "'", "-" }, { "\"", "-" },
{ "´", "-" }, { "`", "-" },
{ "", "-" }, { "#", "-" },
{ "", "0" }, { "", "0" },
{ "", "1" }, { "¹", "1" },
{ "", "2" }, { "²", "2" },
@ -167,6 +171,14 @@ const string Export::AsciiDoc::replace_in_title(const string &text) const
return replace(text, {{ "]", "\\]" }});
}
const string Export::AsciiDoc::replace_in_uri(const string &text) const
{
return replace(text,
{
{ "[", "%5B" }, { "]", "%5D" }
});
}
void Export::AsciiDoc::print_tags(const tagmap &tags) const
{
_out << "== Tags\n\n";

View File

@ -43,6 +43,8 @@ namespace Export
const string replace_in_tag(const string &text) const;
//! Replaces characters in title that asciidoctor doesn't like.
const string replace_in_title(const string &text) const;
//! Replaces characters in URI that asciidoctor doesn't like.
const string replace_in_uri(const string &text) const;
void print_tags(const tagmap &tags) const;
const string get_day(const Database::entry &entry) const;
const string get_time(const Database::entry &entry) const;

View File

@ -64,7 +64,7 @@ const html_extract URI::get()
return
{
extract_title(answer),
strip_html(extract_description(answer)),
extract_description(answer),
strip_html(answer)
};
}
@ -106,7 +106,7 @@ const string URI::extract_description(const string &html)
smatch match;
const regex re("description\"[^>]+content=\"([^\"]+)", icase);
regex_search(html, match, re);
return remove_newlines(match[1].str());
return remove_newlines(strip_html(match[1].str()));
}
return "";
@ -509,11 +509,18 @@ const string URI::archive()
const string URI::remove_newlines(string text)
{
size_t pos = 0;
while ((pos = text.find("\n", pos)) != std::string::npos)
size_t posn = 0;
while ((posn = text.find('\n', posn)) != std::string::npos)
{
text.replace(pos, 1, " ");
++pos;
text.replace(posn, 1, " ");
size_t posr = posn - 1;
if (text[posr] == '\r')
{
text.replace(posr, 1, " ");
}
++posn;
}
return text;
}

View File

@ -55,7 +55,8 @@ SCENARIO ("The AsciiDoc export works correctly")
":Author: +remwharead \\d+\\.\\d+\\.\\d+\n"
":Date: +\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\n"
":TOC: +right\n"
":TOCLevels: +2\n\n");
":TOCLevels: +2\n"
":!webfonts:\n\n");
const regex re_dates
("== 1970-01-01\n\n"
"\\[\\[dt_1970-01-01T\\d{2}:\\d{2}:\\d{2}\\]\\]\n"