aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest4
-rw-r--r--mod/mod-package-details.cxx8
-rw-r--r--mod/mod-package-version-details.cxx8
-rw-r--r--mod/page.cxx19
-rw-r--r--mod/page.hxx9
5 files changed, 43 insertions, 5 deletions
diff --git a/manifest b/manifest
index 8f83c10..a340a3f 100644
--- a/manifest
+++ b/manifest
@@ -23,8 +23,8 @@ depends: * bpkg >= 0.10.0
requires: ? cli ; Only required if changing .cli files.
depends: libapr1
depends: libapreq2
-depends: libcmark-gfm [0.29.0-a.0.1 0.29.0-a.1]
-depends: libcmark-gfm-extensions [0.29.0-a.0.1 0.29.0-a.1]
+depends: libcmark-gfm == 0.29.0-a.1
+depends: libcmark-gfm-extensions == 0.29.0-a.1
depends: libstudxml ^1.1.0-b.6
depends: libodb [2.5.0-b.14.1 2.5.0-b.15)
depends: libodb-pgsql [2.5.0-b.14.1 2.5.0-b.15)
diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx
index fa073b5..5074eca 100644
--- a/mod/mod-package-details.cxx
+++ b/mod/mod-package-details.cxx
@@ -189,9 +189,15 @@ handle (request& rq, response& rs)
const string what (name.string () + " description");
s << (full
- ? DIV_TEXT (*d, *pkg->description_type, id, what, error)
+ ? DIV_TEXT (*d,
+ *pkg->description_type,
+ true /* strip_title */,
+ id,
+ what,
+ error)
: DIV_TEXT (*d,
*pkg->description_type,
+ true /* strip_title */,
options_->package_description (),
url (!full, squery, page, id),
id,
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index 82221b4..40cbad6 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -187,9 +187,15 @@ handle (request& rq, response& rs)
const string what (title + " description");
s << (full
- ? DIV_TEXT (*d, *pkg->description_type, id, what, error)
+ ? DIV_TEXT (*d, *
+ pkg->description_type,
+ true /* strip_title */,
+ id,
+ what,
+ error)
: DIV_TEXT (*d,
*pkg->description_type,
+ true /* strip_title */,
options_->package_description (),
url (!full, id),
id,
diff --git a/mod/page.cxx b/mod/page.cxx
index 63bb495..228a137 100644
--- a/mod/page.cxx
+++ b/mod/page.cxx
@@ -933,6 +933,21 @@ namespace brep
cmark_parser_finish (parser.get ()),
[] (cmark_node* n) {cmark_node_free (n);});
+ // Strip the document "title".
+ //
+ if (strip_title_)
+ {
+ cmark_node* child (cmark_node_first_child (doc.get ()));
+
+ if (child != nullptr &&
+ cmark_node_get_type (child) == CMARK_NODE_HEADING &&
+ cmark_node_get_heading_level (child) == 1)
+ {
+ cmark_node_unlink (child);
+ cmark_node_free (child);
+ }
+ }
+
// Render the AST into an XHTML fragment.
//
// Note that unlike GitHub we follow the default API behavior and
@@ -973,7 +988,9 @@ namespace brep
s.resume_indentation ();
if (f.truncated)
- s << DIV(CLASS="more") << A(HREF=*url_) << "More" << ~A << ~DIV;
+ s << DIV(CLASS="more")
+ << "... " << A(HREF=*url_) << "More" << ~A
+ << ~DIV;
s << ~DIV;
}
diff --git a/mod/page.hxx b/mod/page.hxx
index 1138a80..7260031 100644
--- a/mod/page.hxx
+++ b/mod/page.hxx
@@ -589,6 +589,10 @@ namespace brep
// description element instead. Note that such an error indicates an issue
// with the implementation, rather than with the specified text.
//
+ // Optionally strip the heuristically detected document "title". Currently,
+ // this only applies to Markdown where a leading level-one heading is
+ // assumed to be the title.
+ //
class DIV_TEXT
{
public:
@@ -596,11 +600,13 @@ namespace brep
//
DIV_TEXT (const string& t,
text_type tp,
+ bool st,
const string& id,
const string& what,
const basic_mark& diag)
: text_ (t),
type_ (tp),
+ strip_title_ (st),
length_ (t.size ()),
url_ (nullptr),
id_ (id),
@@ -613,6 +619,7 @@ namespace brep
//
DIV_TEXT (const string& t,
text_type tp,
+ bool st,
size_t l,
const string& u,
const string& id,
@@ -620,6 +627,7 @@ namespace brep
const basic_mark& diag)
: text_ (t),
type_ (tp),
+ strip_title_ (st),
length_ (l),
url_ (&u),
id_ (id),
@@ -634,6 +642,7 @@ namespace brep
private:
const string& text_;
text_type type_;
+ bool strip_title_;
size_t length_;
const string* url_; // Full page url.
string id_;