Bug 145925 - AutoCorrect DOI (ISO 26324) recognition
Summary: AutoCorrect DOI (ISO 26324) recognition
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Baole Fang
URL: https://doi.org/10.1000/182
Whiteboard: target:7.6.0
Keywords: difficultyInteresting, easyHack, skillCpp
Depends on:
Blocks: AutoFilter Hyperlink Authors DoAsMacro
  Show dependency treegraph
 
Reported: 2021-11-28 10:51 UTC by FM
Modified: 2023-05-03 17:07 UTC (History)
8 users (show)

See Also:
Crash report or crash signature:


Attachments
video testing the bug (1.38 MB, video/mp4)
2023-04-27 13:49 UTC, BogdanB
Details
video testing the bug (628.85 KB, video/mp4)
2023-04-27 14:41 UTC, BogdanB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description FM 2021-11-28 10:51:27 UTC
Description:
Feature request:

In Writer, there is an AutoCorrect option that can turn https:// urls automatically into hyperlinks.

In science, e.g. when using Zotero, it is very common to cite papers with the format doi:10.1259/bjr.20190594

It would be really great if there is a further option in the AutoCorrect menu, called "DOI recognition", which adds behind the scenes a hyperlink to https://doi.org/10.1259/bjr.20190594 (without changing the text itself).

Steps to Reproduce:
1. Write doi:10.1259/bjr.20190594
2. Select text and click Tools, AutoCorrect, Apply

Actual Results:
Nothing happens

Expected Results:
Hyperlink is inserted https://doi.org/10.1259/bjr.20190594
if a checkbox "DOI recognition" is activated in Tools, AutoCorrect, Autocorrect Options, no 


Reproducible: Always


User Profile Reset: No



Additional Info:
Related issues:
https://forums.zotero.org/discussion/65658/bibliography-in-libreoffice-clickable-doi
https://forums.zotero.org/discussion/76312/csl-style-with-doi-hyperlinks
https://forums.zotero.org/discussion/71519/doi-does-not-appear-as-a-link
https://forums.zotero.org/discussion/7534/hyperlinking-citations-to-bibliography-in-openoffice
https://ask.libreoffice.org/t/how-may-i-do-writer-recognize-hyperlinks-automatically/1860/4

Version: 6.0.7.3
Build ID: 1:6.0.7-0ubuntu0.18.04.10
CPU threads: 8; OS: Linux 5.4; UI render: default; VCL: gtk3; 
Locale: en-US (en_US.UTF-8); Calc: group
Comment 1 Michael Warner 2021-11-28 16:51:03 UTC
This could be a nice macro or extension that someone writes, but I don't think it should be a core feature. It's too narrow of a use case. What if DOI changes how they link things? What if someone wants their DOI references linked to somewhere else? 

Generalizing this request to something that attempts to match a user-supplied pattern and automatically runs a user-supplied macro on that match automatically in the background might be a little more defensible as a core feature, but even then I would say adding that feature is a low priority.
Comment 2 Dieter 2022-12-28 11:41:14 UTC
(In reply to Michael Warner from comment #1)

I supprt this feature request

> This could be a nice macro or extension that someone writes, but I don't
> think it should be a core feature. It's too narrow of a use case. What if
> DOI changes how they link things?
Could be a question for every hyperlink. And basic idea of the DOI-concept is, that hyperlink is stable.

> What if someone wants their DOI references
> linked to somewhere else?

I'm not sure, how familiar you are with DOI. But it is a reference and if you use it, you don't want to link somewhere else.

cc: Design-Team for further input and decision
Comment 3 V Stuart Foote 2022-12-28 13:52:23 UTC
Yes, the DOI (ISO 26324) is by its nature stable (and the Publisher of the DOI is responsible for maintaining linkage to its related resource).

Adding an LO autocorrection to parse and convert a DOI formatted tag (i.e. the reference string prepended with "doi:") into a valid URI is reasonable enhancement to core.

+1 to implement, and recognize its usefulness to context of see also bug 121945
Comment 4 V Stuart Foote 2022-12-28 14:03:13 UTC
@Lásló, your opinion of an autocorrect function and vcl handling for this?
Comment 5 Heiko Tietze 2023-01-05 10:41:09 UTC
Some agreement here, and I just wonder if we need the leading "http://". Typing the last letter would add it before "doi:" making the text jumping. The hyperlink can have a different link and include the protocol.

Sounds like an interesting task and I'd start at editeng/source/misc/acorrcfg.cxx SetInetAttribute, and editeng/source/editeng/edtspell.cxx EdtAutoCorrDoc::SetINetAttr().
Comment 6 Baole Fang 2023-03-24 03:15:27 UTC
Start working on this.
Comment 7 Baole Fang 2023-04-25 05:37:36 UTC
I've submitted a patch to:
https://gerrit.libreoffice.org/c/core/+/150954

Can anyone review it?
Comment 8 Commit Notification 2023-04-27 13:28:19 UTC
Baole Fang committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/a772976f047882918d5386a3ef9226c4aa2aa118

tdf#145925: Add DOI recognition

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 BogdanB 2023-04-27 13:47:04 UTC
Not working with doi:10.1259/bjr.20190594.

The setting is activated in Tools - Autocorrect - Autocorrect Options.

Nothing happened.

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: a772976f047882918d5386a3ef9226c4aa2aa118
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 10 BogdanB 2023-04-27 13:49:29 UTC
Created attachment 186968 [details]
video testing the bug
Comment 11 Baole Fang 2023-04-27 14:01:00 UTC
(In reply to BogdanB from comment #10)
> Created attachment 186968 [details]
> video testing the bug

Hi, this is caused by the other bug I mentioned in bug 155018, which is a duplicate of bug 128192 and also related to bug 90507. Notice that your style is currently "Text Body", where Tools/AutoCorrect/Apply only works for default style without my patch: https://gerrit.libreoffice.org/c/core/+/151008.
Comment 12 BogdanB 2023-04-27 14:41:26 UTC
Created attachment 186969 [details]
video testing the bug

I tried one more time.
The text is in "Default Paragraph Style", and after Tools-Autocorrect-Apply it became "Text body" and "doi:10.1259/bjr.20190594" became "Doi:10.1259/bjr.20190594".
Comment 13 Baole Fang 2023-04-27 15:15:00 UTC
This is caused by auto capitalize. If you keep the first "D" as lower case, it should work.
Comment 14 Baole Fang 2023-04-27 15:17:25 UTC
Maybe you can try typing something random in the beginning of the line and add a space, and then type the doi. eg.

abc doi:10.1259/bjr.20190594
Comment 15 BogdanB 2023-04-27 15:38:29 UTC
Yes, it is working like that, with
abc doi:10.1259/bjr.20190594

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: a772976f047882918d5386a3ef9226c4aa2aa118
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

But, for the future, you should also take this case of beginning a new line with a doi.
Comment 16 Baole Fang 2023-04-27 15:51:37 UTC
(In reply to BogdanB from comment #15)
> Yes, it is working like that, with
> abc doi:10.1259/bjr.20190594
> 
> Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
> Build ID: a772976f047882918d5386a3ef9226c4aa2aa118
> CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
> Locale: ro-RO (ro_RO.UTF-8); UI: en-US
> Calc: threaded
> 
> But, for the future, you should also take this case of beginning a new line
> with a doi.

Yeah, I can definitely support this case, just like what url recognition does. In url recognition, if you type www.google.com, it will become a hyperlink with text Www.google.com. I wasn't sure whether this should be expected before. If it is agreed that we can recognize doi even if the first character is captilized, I can implement it quickly.
Comment 17 Commit Notification 2023-05-03 05:55:25 UTC
Baole Fang committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e8d7bf954fe74ce85bdd084d6e12d27027a4c379

tdf#145925: Support AutoCapitalize in DOI recognition

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 18 BogdanB 2023-05-03 15:54:02 UTC
Working very well now.
You can mark this bug as resolved, IF everything you planned is done.

I tested in 2 ways:
- Write doi:10.1259/bjr.20190594 Select text and click Tools, AutoCorrect, Apply: GOOD
- Write doi:10.1259/bjr.20190594 and press Enter: GOOD

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: bb198176684c3d9377e26c04a29ec66deb811949
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 19 FM 2023-05-03 16:16:57 UTC
Thanks so much!!!!
Comment 20 BogdanB 2023-05-03 16:24:29 UTC
Verified with
Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: bb198176684c3d9377e26c04a29ec66deb811949
CPU threads: 16; OS: Linux 5.19; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 21 Baole Fang 2023-05-03 16:47:36 UTC
You are welcome. Let me know if there is any more question.
Comment 22 BogdanB 2023-05-03 17:01:28 UTC
Baole, please don't change back from verified status.
Verified is better than resolved. 

One bug is "resolved" when you decide that you have done what is needed. The same bug is "verified" when others test it and see that you indeed have done that job. I am the one that have verified that you have done a good job.
Comment 23 Baole Fang 2023-05-03 17:07:05 UTC
Got it.