From 6840a9d0d722b4e20783077c560337f140897230 Mon Sep 17 00:00:00 2001 From: Eason Goodale Date: Sat, 13 Aug 2016 22:11:01 -0700 Subject: [PATCH] Fixes crash when html has an xml version tag by stripping it out --- lib/readability.ex | 1 + lib/readability/helper.ex | 1 + test/fixtures/pubmed.html | 308 ++++++++++++++++++++++++++++++++++++++ test/readability_test.exs | 15 ++ 4 files changed, 325 insertions(+) create mode 100644 test/fixtures/pubmed.html diff --git a/lib/readability.ex b/lib/readability.ex index 5687c98..4d10f41 100644 --- a/lib/readability.ex +++ b/lib/readability.ex @@ -55,6 +55,7 @@ defmodule Readability do div_to_p_elements: ~r/<(a|blockquote|dl|div|img|ol|p|pre|table|ul)/i, replace_brs: ~r/(]*>[ \n\r\t]*){2,}/i, replace_fonts: ~r/<(\/?)font[^>]*>/i, + replace_xml_version: ~r/<\?xml.*\?>/i, normalize: ~r/\s{2,}/, video: ~r/\/\/(www\.)?(dailymotion|youtube|youtube-nocookie|player\.vimeo)\.com/i, protect_attrs: ~r/^(?!id|rel|for|summary|title|href|src|alt|srcdoc)/i diff --git a/lib/readability/helper.ex b/lib/readability/helper.ex index 604be68..f77cfff 100644 --- a/lib/readability/helper.ex +++ b/lib/readability/helper.ex @@ -92,6 +92,7 @@ defmodule Readability.Helper do @spec normalize(binary) :: html_tree def normalize(raw_html) do raw_html + |> String.replace(Readability.regexes[:replace_xml_version], "") |> String.replace(Readability.regexes[:replace_brs], "

") |> String.replace(Readability.regexes[:replace_fonts], "<\1span>") |> String.replace(Readability.regexes[:normalize], " ") diff --git a/test/fixtures/pubmed.html b/test/fixtures/pubmed.html new file mode 100644 index 0000000..a38adbc --- /dev/null +++ b/test/fixtures/pubmed.html @@ -0,0 +1,308 @@ + + + + + + + + + + + + Antihypertensive efficacy of the losartan/hydrochlorothiazide combination and its effect on plasma B-type natriuretic peptide in hypertensive patie... - PubMed - NCBI + + + + + + + + + + + + + + + +

+
+
+
+ + + +
+ +
+ + + + +
+
+ +
+
+
Format

Send to

Choose Destination
+
+ + + + + + +
+
+
+ +
+
+ + + + +
+
See comment in PubMed Commons below
Clin Drug Investig. 2012 Mar 1;32(3):171-8. doi: 10.2165/11597620-000000000-00000.

Antihypertensive efficacy of the losartan/hydrochlorothiazide combination and its effect on plasma B-type natriuretic peptide in hypertensive patients uncontrolled by angiotensin II type 1 receptor antagonist-based therapy: a multicentre prospective observational study.

Author information

  • 1Department of Cardiology and Internal Medicine, Fukuoka Red Cross Hospital, Fukuoka, Japan. hiroshimeno@fukuoka-med.jrc.or.jp

Abstract

BACKGROUND AND OBJECTIVES:

Although strict blood pressure (BP) control is effective in the prevention of cardiovascular events, it is often insufficient in many hypertensive patients. B-type natriuretic peptide (BNP) has been shown to be associated with cardiovascular events. We investigated the effects of the losartan/hydrochlorothiazide combination on BP and plasma BNP in hypertensive patients uncontrolled by an angiotensin II type 1 receptor antagonist (angiotensin receptor blocker [ARB])-based therapy.

METHODS:

In a multicentre prospective observational study, we enrolled 185 patients aged 36-79 years (mean age 63.8 years) with essential hypertension but without symptoms of heart failure who received an ARB-based therapy for ≥3 months but failed to achieve a target BP recommended by the Japanese Society of Hypertension (JSH). ARBs were switched to losartan (LOS) 50 mg/hydrochlorothiazide (HCTZ) 12.5 mg. The antihypertensive efficacy, safety, and effects of this combination on blood biochemical parameters and plasma BNP were evaluated for 12 months.

RESULTS:

Mean ± SD systolic and diastolic BP decreased from 152 ± 13/87 ± 10 mmHg to 128 ± 14/74 ± 10 mmHg, respectively, after 12 months (p < 0.001). Mean ± SD plasma BNP levels decreased significantly from 46.0 ± 83.0 pg/mL to 40.8 ± 68.0 pg/mL (p < 0.05). The percentage of patients who achieved the JSH 2004 target BP was 51% after 12 months; the percentage was 63% in elderly patients aged ≥65 years without complications, and 43% in patients with concomitant diabetes mellitus or chronic kidney disease. No association was found between a decrease in plasma BNP levels and BP, age, body mass index or estimated glomerular filtration rate. There was a significant increase in serum uric acid and a decrease in serum potassium, but both were within the range of normal values. Adverse events were observed in 8.6% of the patients.

CONCLUSION:

Antihypertensive treatment using two types of drugs (LOS/HCTZ) with different mechanisms yielded potent antihypertensive efficacy with safety and decreased plasma BNP levels.

[PubMed - indexed for MEDLINE]
PubMed Commons home

+ PubMed Commons +

0 comments
How to join PubMed Commons
    +
    + +
    +
    + + +
    + +
    +
    +
    +

    Supplemental Content

    + +
    + +

    Full text links

    Icon for Springer
    + + + +
    Loading ...
    + + +
    + + +
    +
    + +
    + + Write to the Help Desk + +
    + + + +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/test/readability_test.exs b/test/readability_test.exs index b4b1947..0b93d83 100644 --- a/test/readability_test.exs +++ b/test/readability_test.exs @@ -59,4 +59,19 @@ defmodule ReadabilityTest do assert buzzfeed_text =~ ~r/^The FBI no longer needs Apple’s help/ assert buzzfeed_text =~ ~r/issue of court orders and encrypted devices.$/ end + + test "readability for pubmed" do + html = TestHelper.read_fixture("pubmed.html") + pubmed = Readability.article(html) + + pubmed_html = Readability.readable_html(pubmed) + + assert pubmed_html =~ ~r/^

    BACKGROUND AND OBJECTIVES: <\/h4>

    Although strict blood pressure/ + assert pubmed_html =~ ~r/different mechanisms yielded potent antihypertensive efficacy with safety and decreased plasma BNP levels.<\/abstracttext><\/p><\/div><\/div>$/ + + pubmed_text = Readability.readable_text(pubmed) + + assert pubmed_text =~ ~r/^BACKGROUND AND OBJECTIVES: \nAlthough strict blood pressure/ + assert pubmed_text =~ ~r/with different mechanisms yielded potent antihypertensive efficacy with safety and decreased plasma BNP levels.$/ + end end