Template:COVID-19 pandemic death rates/doc

From blackwiki
Jump to navigation Jump to search

The data source for this template is here. Copy the 'Cases and mortality by country' table and paste it into tab2wiki. Uncheck all boxes except "Compress table". Click "Do it". At the top delete {| border="1". Then copy all the rest of the table wikitext. Delete the old table data in Template:COVID-19 pandemic death rates, and paste in the updated data. Update the date.

Add country links and flags if you want. It can be done within the wikitext source editor. First go to editing preferences: Special:Preferences#mw-prefsection-editing. Check the box for: "Enable the editing toolbar. This is sometimes called the '2010 wikitext editor'."

Then click on the wikitext source editing link for the table. Click on "Advanced" in the editing toolbar. Then click on the search-and-replace icon on the right. Put a check in the box called "Treat search string as a regular expression." Fill in the "Search for" box with:

(\|-.*\n\|\s*)([^\|\n]*)

Fill in the "replace with" box with:

$1{{flaglist|$2}}

Then click "Replace all". All, or nearly all, countries will be linked, and have flags. This often does not work for the first country, currently San Marino. Fix it.

Change country links to "COVID-19 pandemic in country". This can be done via global find-and-replace in a text editor, or by running a Microsoft Word macro on the text with the VBA code below.

1. Text editor:

Use global find-and-replace in almost any text editor. Or click on the same search-and-replace icon previously discussed. Then uncheck "Treat search string as a regular expression." Replace {{flaglist with:
{{flag+link|COVID-19 pandemic in

Pasting in the amended text works except for Taiwan, Congo (Kinshasa) and China. Change:

  • Taiwan* to Taiwan
  • in|Congo (Kinshasa) to in|DR Congo
  • in|China to in mainland|China

2. VBA code for macro: Copy the code and paste it into an empty macro.

   
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "Belgium|"
        .Replacement.Text = "{{flag+link|COVID-19 pandemic in|Belgium}}|"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Application.WindowState = wdWindowStateMinimize
    Application.WindowState = wdWindowStateNormal
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting

        With Selection.Find
        .Text = "Taiwan*"
        .Replacement.Text = "Taiwan"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "{{flaglist"
        .Replacement.Text = "{{flag+link|COVID-19 pandemic in"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "in|China"
        .Replacement.Text = "in mainland|China"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "in|Congo (Kinshasa)"
        .Replacement.Text = "in |DR Congo"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "|United Kingdom"
        .Replacement.Text = " the|United Kingdom"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "|US"
        .Replacement.Text = " the|United States"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll