Add an unordered list to a Wiki tag

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.