Skip to content

Commit bb7fbda

Browse files
committed
Add hide_references option
1 parent 79e9c0c commit bb7fbda

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/wikicurses/htmlparse.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
from bs4 import BeautifulSoup
55

66
from wikicurses import formats
7+
from wikicurses.settings import conf
78

89
skipclass = ('wiki-sidebar', 'infobox', 'mw-editsection', 'editsection',
910
'wikitable', 'thumb', 'gallery', 'article-thumb')
11+
skipsection = ('Contents', 'External links', 'See also')
1012

13+
if conf.getboolean('general', 'hide_references'):
14+
skipclass += ('reference',)
15+
skipsection += ('References',)
1116

1217
class UrwidMarkupHandler:
1318

@@ -79,7 +84,7 @@ def parseExtract(html):
7984
i.decompose()
8085
sections[''] = _processExtractSection(soup.body or soup)
8186
for i in soup.find_all('h2'):
82-
if i.text not in ('Contents', 'External links', 'See also'):
87+
if i.text not in skipsection:
8388
sections[i.text.strip()] = _processExtractSection(i.next_siblings)
8489
for i in sections:
8590
if not sections[i]:

wikicurses.conf

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[general]
22
default = Wikipedia
33
mouse = False
4+
hide_references = False
45

56
[keymap]
67
q = quit

wikicurses.conf.5

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH wikicurses.conf 5 2014-12-29
1+
.TH wikicurses.conf 5 2015-02-22
22
.SH NAME
33
wikicurses \- curses interface for MediaWiki
44
.SH SYNOPSIS
@@ -12,6 +12,7 @@ The configuration file for wikicurses is divided into sections with the "general
1212
[general]
1313
default = Wikipedia
1414
mouse = False
15+
hide_references = False
1516

1617
[keymap]
1718
q = quit
@@ -41,6 +42,11 @@ mouse
4142
.RS 4
4243
Support mouse input. With this enabled, you will have to hold down shift to select text.
4344
.RE
45+
.PP
46+
hide_references
47+
.RS 4
48+
Hide the References section at the bottom of the page and strip citations from the text.
49+
.RE
4450
.SS keymap
4551
This section configures the keyboard bindings of wikicurses, in the format "key=command". Command can be any ex command supported by wikicurses.
4652
.SS Other Sections

0 commit comments

Comments
 (0)