Module talk:italics

From Wiktionary, the free dictionary
Latest comment: 5 years ago by Erutuon in topic Changes to Template:... and Template:nb...
Jump to navigation Jump to search

Name

[edit]

@Erutuon Since this module concerns italics specifically in the context of taxonomic names, do you think it might be better named Module:taxonomy? That way, we can include other taxonomy-related stuff in there too. —CodeCat 23:13, 31 October 2016 (UTC)Reply

@CodeCat I considered that possibility, but decided against it because the same italicization function can be used for other article names that have a parenthesized disambiguator after them, like Antigone (Sophocles play). I'm not sure if such articles are currently linked to on Wiktionary (I didn't find any examples when I briefly looked), but I decided to name the module so that such links wouldn't be excluded. — Eru·tuon 23:17, 31 October 2016 (UTC)Reply
That makes sense. We may still want to create Module:taxonomy in any case, though. —CodeCat 23:18, 31 October 2016 (UTC)Reply

Use in "quote-meta/source"

[edit]

Hi, @Erutuon. The recent discussion and use of this module at {{taxlink}} got me thinking about whether this module can be used to adjust italicization in the titles of works at {{cite-meta}} and {{quote-meta/source}}. Currently, the title of a work is italicized using <cite> tags. However, when a title is long it is sometimes desirable to use ellipses to omit parts of it. These ellipses should, ideally, not be italicized:

Not so good: A Voyage around the World. [...] In Two Volumes.
Much better: A Voyage around the World. [...] In Two Volumes.

At the moment, the only way to achieve the second result is to use the following ugly hack: |title=A Voyage around the World. </cite>[...]<cite> In Two Volumes. Would it be possible to create another function in this module to search for occurrences of "[...]", "{{...}}" and "{{nb...}}" and turn off the italicization? If so, I'd also be grateful if you would assist in updating {{cite-meta}} and {{quote-meta/source}} (or explain to me how to do so) so that they invoke this module. Thanks. — SGconlaw (talk) 15:14, 30 July 2017 (UTC)Reply

In fact, just thinking about it, perhaps italicization should be turned off for any use of the left or right brackets within the title of a work, as that would indicate an editorial interpolation not originally in the title, like this: A Response to a Scurrilous Libel by J[onathan] S[wift]. [...] In Two Volumes.SGconlaw (talk) 15:18, 30 July 2017 (UTC)Reply

@Erutuon, what do you think? Any chance you can look into it? — SGconlaw (talk) 22:08, 10 August 2017 (UTC)Reply

It should be possible. However, handling {{...}} will be a little more complicated than the literal [...], because the module will be searching the wikitext that it generates. — Eru·tuon 22:15, 10 August 2017 (UTC)Reply
I'm not sure how often {{...}} or {{nb...}} occurs in titles. Maybe we can start with handling [...] and [ and ] first? — SGconlaw (talk) 01:51, 11 August 2017 (UTC)Reply
Okay, I've done that. See the documentation page. — Eru·tuon 02:38, 11 August 2017 (UTC)Reply
Thanks! However, I modified {{quote-meta/source}} (see this diff), but it doesn't seem to work. See the 1666 quotation in merlion. Have I invoked it wrongly? — SGconlaw (talk) 06:54, 11 August 2017 (UTC)Reply
Yeah, it appears to be because the template uses <cite></cite> tags to produce italics, while I am using '', which translates to <i></i> tags. Anyway, the function needs more testing before it can be used, and I am not sure how to get a representative selection of titles to test it with. — Eru·tuon 20:21, 11 August 2017 (UTC)Reply
Actually, when I tried updating the template I removed all the <cite> tags entirely and replaced them with {{#invoke:italics}}. Was this incorrect? Here are some entries that you can test with: darrein (1793, 1825 and 1845 quotes), merlion (etymology 2, 1666 quote), {{RQ:Austen Persuasion}}. — SGconlaw (talk) 12:31, 12 August 2017 (UTC)Reply

──────────────────────────────────────────────────────────────────────────────────────────────────── @Erutuon, any chance you have time to look into this again? — SGconlaw (talk) 02:33, 29 November 2017 (UTC)Reply

@Sgconlaw: I have time, but have to consider how best to implement deitalicization within cite tags. I don't think removing the cite tags and replacing them with '' is the right solution. It might be better to leave the tag, because it is semantically valid, but add inline CSS around the text to be deitalicized: <span style="font-style: normal;"></span>. In response to your previous post, the module isn't ready to use. — Eru·tuon 02:52, 29 November 2017 (UTC)Reply
OK, thanks for looking into this! Let me know when it's ready for implementation in {{cite-meta}} and {{quote-meta/source}}. — SGconlaw (talk) 04:15, 29 November 2017 (UTC)Reply
@Sgconlaw: A beta version is available. You can invoke it thus: {{#invoke:italics|unitalicize_brackets|text}}. — Eru·tuon 07:04, 13 January 2018 (UTC)Reply
@Erutuon: thanks! However, it doesn't seem to work as predicted. I edited {{quote-meta/source}} to add the module to the parameters |chapter=, |trans-chapter=, |title=, and |trans-title=, but it seems to have removed italicization from the title altogether if the title contains brackets. See, for example, {{RQ:Chambers Cyclopaedia}} and consistent. Italicization was done using <cite> tags, but it doesn't make a difference whether I use that or ''. Also, the remainder of the reference after the title (publication place, name of publisher, etc.) is now italicized. — SGconlaw (talk) 13:18, 14 January 2018 (UTC)Reply
However, strangely enough, it works properly at {{RQ:Lovell Panzooryktologia}}. Could it be because the title in {{RQ:Chambers Cyclopaedia}} is within a wikilink? — SGconlaw (talk) 16:20, 14 January 2018 (UTC)Reply
Yes, it was the wikilink. The function was simply looking for brackets and didn't care to distinguish wikilinks from brackets that couldn't be wikilinks. There are probably other cases that won't be handled correctly, so let me know if you notice any. — Eru·tuon 21:21, 14 January 2018 (UTC)Reply
Thanks for fixing it! Will do. — SGconlaw (talk) 02:08, 15 January 2018 (UTC)Reply

──────────────────────────────────────────────────────────────────────────────────────────────────── Hi, @Erutuon. I noticed that in the 1850 quotation at sassywood, the text within the brackets is no longer in italics. I think only the brackets themselves should not be italicized; the text within them should be:

  • Current: Rev. R[alph] R[andolph] Gurley
  • Preferred: Rev. R[alph] R[andolph] Gurley

SGconlaw (talk) 19:12, 18 January 2018 (UTC)Reply

@Sgconlaw: Ah. And should ellipses not be italicized? Not that it matters visually. — Eru·tuon 19:17, 18 January 2018 (UTC)Reply
Done. And I also fixed external links, mentioned in Template talk:cite-meta § Broken templates. — Eru·tuon 22:27, 18 January 2018 (UTC)Reply
Thanks! Sure, ellipses should remain unitalicized, but as you said it's probably not visually detectable either way. — SGconlaw (talk) 03:11, 19 January 2018 (UTC)Reply

Changes to Template:... and Template:nb...

[edit]

Hi, @Erutuon, could you please update this module so that it recognizes the changes that have been made to {{...}} and {{nb...}} to avoid Lint errors? Thanks, and merry Christmas! — SGconlaw (talk) 08:12, 25 December 2018 (UTC)Reply

@ShakespeareFan00: What do you mean by "missing span" in this example ({{#invoke:italics|test|[https://en.wiktionary.org/wiki/Wiktionary:Main_Page A sample item containing a continuation, [&c {{...}}]]<!-- This fails currently, Generates a missing span... -->}})? Are you referring to the fact that the second of the closing brackets isn't enclosed in <span class="hellip-b"></span>? — Eru·tuon 19:07, 25 December 2018 (UTC)Reply
Yes. The missing span is a Linter Error. It typically means the parser is getting confused about where the 'end' of something is. In this instance I think it's confusing the end ] of the  [] with the end of a link, and mismatching the opening/closing brackets of what it thinks is a link (wrapped by an enclosing span.) ShakespeareFan00 (talk) 19:10, 25 December 2018 (UTC)Reply
Okay. Well, that can be fixed by changing some of the brackets to HTML character references, but I don't know if the module should do it, unless there is some clear way to determine which brackets belong to the external link syntax. — Eru·tuon 19:16, 25 December 2018 (UTC)Reply
I changed the brackets in {{...}} and {{nb...}} to HTML character references. If any bracket that is not supposed to be interpreted as link syntax is given as HTML character reference ([ ], [ ]) or enclosed in nowiki tags (<nowiki>[</nowiki> <nowiki>]</nowiki>), that keeps the parser from misidentifying the start and end of the link. — Eru·tuon 19:33, 25 December 2018 (UTC)Reply
However, the module is no longer working the way it used to – now if {{...}} or {{nb...}} are used in a quotation, the brackets are appearing italicized. See, for example, {{RQ:Defoe Crusoe}} (which appears in box). Also, {{nb...}} has failed entirely in the Wilson quotation under sense 1.17 in box, producing "[<span title="With an Illustrative Glossary, by Captain Thomas Brown, [...]">…]". (Frankly, I'm beginning to wonder why is it necessary to avoid Lint errors at all, since they do not seem to affect anything.) — SGconlaw (talk) 21:35, 25 December 2018 (UTC)Reply
Right. Should've thought of that. Lua can't easily identify HTML character references for matching brackets (without LPeg). I've undone my edits. — Eru·tuon 22:02, 25 December 2018 (UTC)Reply

Fails when portion to de-italicized is at the start of the parameter with no proceeding italic portion

[edit]

Test case :

Test case Actual output Desired output.
{{#invoke:italics|i|× Agroelymus}}
''''× ''Agroelymus''
× ''Agroelymus''

In this instance the function should be moving the start of the italic portion until after the x or other de-italicized portion.ShakespeareFan00 (talk) 08:28, 25 December 2018 (UTC)Reply

Modified the code to remove quadruple single quotes. — Eru·tuon 19:22, 25 December 2018 (UTC)Reply