Items: Adding unordered lists to Wiki tags
When editing an article in Wikipedia, you can create an unordered list that makes each item
and place an asterisk in front of it. But suppose you have a very large list and want to add the front
The asterisk. You can enter these asterisks at the beginning of each line, one line after the other. Or you can use a short
Python script to automate this task.
The bulletpointadder.py script will take the text from the Clipboard, with an asterisk and a blank at the beginning of each line
And then paste the new text back into the Clipboard. For example, if I copy the following text to the Clipboard
(Taken from Wikipedia article "List of Lists of Lists"):
Lists of Animals
Lists of Aquarium life
Lists of biologists by author abbreviation
Lists of cultivars
Then run the bulletpointadder.py program and the Clipboard will contain the following content:
* Lists of animals
* Lists of Aquarium life
* Lists of biologists by author abbreviation
* Lists of cultivars
This text, preceded by an asterisk, can be pasted back into Wikipedia's article as an unordered list.
Copy and paste from the Clipboard
You want the bulletpointadder.py program to do the following things:
1. Pastes text from the Clipboard;
2. Do some processing on it;
3. Copies the new text to the Clipboard.
Code implementation:
bulletpointadder.py
1 ImportPyperclip2 3Text =pyperclip.paste ()4 5LST = Text.split ('\ r \ n')#splits a string into a list with \ r \ n as a delimiter6 7 forIinchRange (len (LST)):8Lst[i] ='* '+ Lst[i]#Add ' * ' before each element of the list9 TenText ='\ n'. Join (LST)#to synthesize a list into a string One A pyperclip.copy (text) - Print(Pyperclip.paste ())
Add an unordered list to a Wiki tag