from wikicurses.wiki import Wiki
wiki = Wiki.fromPageUrl('http://en.wikipedia.org')
article = wiki.search('Linux')
print(''.join(i[1] for i in article.content))
I'd like to save the output to text instead of displaying it. I've tried piping it to tee with no luck. I came across instructions on how to output a man page to text:
man wikicurses | col -bx > output.txt
This doesn't work either. Is there any way pipe the output to a file? If this is not possible from a curses application like this, do you plan on adding a "print" type function? My goal is to script a list of ~50 wikipedia articles and save them for offline terminal reading.
Kind of like this but not on such a large scale - http://www.evanjones.ca/software/wikipedia2text.html
]]>Also the Warning and Tip notes, which can be identified by <div> tags in the HTML, could be spaced from the surrounding text to make them more outstanding.
Obviously that can't be done do every <div> tag, since modern html code has divs everywhere. I guess the solution would be to parse the style attribute and add padding when padding is included. It might be possible to also respect the css border and add a border around it as well. I think that will work, and it will probably be useful for some other wikis as well.
I'd suggest to try to detect the blocks the page is made of and insert a (single) blank line between them to make the result more readable. The code (inside <pre> tags) could also be indented. It may be hard to implement consistently for various wikis, but I think it's worth a try. What do you say?
The code currently adds a blank line after </p> tags. I can make it do the same for other block-level elements like <pre>. As for indenting <pre> tags, do you know if that would cause issues with other wikis?
Edit: Indenting/padding certain blocks of text will require some somewhat complicated changes to how text is displayed in wikicurses. Not to say I won't do that, but for now I have just made <pre> tags green (by default, colors are customizable). Not perfect, but the code stands out well.
]]>The usability is already pretty high, there is just one thing that struck me: the spacing of the blocks on the page is IMHO wrong. Consider the following example (from the Beginners' guide):
Connect automatically to known networks
Warning: This method cannot be used with explicitely enabled profiles, i.e. through netctl enable profile.
Install wpa_actiond, which is required for netctl-auto:
# pacman -S wpa_actiond
Enable the netctl-auto service, which will connect to known networks and gracefully handle roaming and disconnects:
# systemctl enable netctl-auto@interface_name.service
Tip: netctl also provides netctl-ifplugd, which can be used to handle wired profiles in conjunction with netctl-auto.
Here, the first line is the section title and it appears as bright white, underlined in the terminal, but the rest appears quite unreadable. The code lines starting with '#' blend with the text followed, there is a blank line before but not after the code line. Also the Warning and Tip notes, which can be identified by <div> tags in the HTML, could be spaced from the surrounding text to make them more outstanding.
I'd suggest to try to detect the blocks the page is made of and insert a (single) blank line between them to make the result more readable. The code (inside <pre> tags) could also be indented. It may be hard to implement consistently for various wikis, but I think it's worth a try. What do you say?
I'll surely take a look at the code when I find some time, I could potentially make use of it to implement some interactive features planned for wiki-scripts.
]]>Other than colors, I have also added a :langs command to see a page in different languages, as well as some bug fixes and other small changes.
]]>Nice project. Any plans to add colour options in the config?
Having different colours for titles and links could be neat
Good idea. I have added it to TODO and will implement it when I have time.
]]>Having different colours for titles and links could be neat
]]>