Bug 115418 - Apply character style on markdown-like auto-correction (e.g. *bold*)
Summary: Apply character style on markdown-like auto-correction (e.g. *bold*)
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
Depends on:
Blocks: AutoCorrect-Complete
  Show dependency treegraph
Reported: 2018-02-02 23:06 UTC by Leandro Martín Drudi
Modified: 2018-11-13 13:24 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Note You need to log in before you can comment on or make changes to this bug.
Description Leandro Martín Drudi 2018-02-02 23:06:39 UTC
It is currently used to write a word between * to put it in bold, between bars for italics, etc.
This applies direct formatting. I suggest that it should be optional if it is direct formatting or if corresponding text styles are applied.

Steps to Reproduce:
No apply

Actual Results:  
Applies direct format.

Expected Results:
If I select "Direct format", applies direct format.
If I select "Apply text Style", apply "Strong Enphasis" if wrote *strong*, or apply "Emphasis" if wrote /emphasis/

Reproducible: Always

User Profile Reset: No

Additional Info:
It helps to export ePub in same personalized Styles or with own styles.

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
Comment 1 RGB 2018-02-03 16:04:17 UTC
This would be an interesting enhancement, indeed!

Right now it's possible to set keyboard shortcuts also for character styles (there are already several predefined for paragraph styles) so it should be possible to set some kind of "activator" (either default keyboard shortcuts or something else) for common character styles.

Great idea!

PD: set version as "Inherited from OOo"
Comment 2 Heiko Tietze 2018-02-26 08:57:44 UTC
You ask for markdown [1] in a WYSIWYG text processor? Meaning instead of ctrl+B/click on the toolbar etc. you want to type *FOO* and the text is magically changed into <style:bold>FOO</style>. If that is what you request it is out of scope in my opinion.
Asking for a specific clipboard format is something different. But in both cases I would recommend to do that per extension.

[1] https://en.wikipedia.org/wiki/Markdown
Comment 3 Cor Nouws 2018-02-27 18:50:32 UTC
(In reply to Heiko Tietze from comment #2)
> You ask for markdown [1] in a WYSIWYG text processor? Meaning instead of
> ctrl+B/click on the toolbar etc. you want to type *FOO* and the text is
> magically changed into <style:bold>FOO</style>. If that is what you request
> it is out of scope in my opinion.

See Tools > Autocorrect Options > tab Options. It already is there.
And applies direct formatting.
The suggestion is to make it possible, that not DF is applied, but relevant character styles.

Sounds as a reasonable idea, IMO.
Comment 4 Leandro Martín Drudi 2018-02-27 23:31:00 UTC
It can be optional to the user.
To export to ePub is recommended Text Styles instead direct format because in HTML design is recommended a Class (.bold) istead a tag (<strong>, for example).
Comment 5 Thomas Lendo 2018-02-28 00:47:32 UTC
Why not go with character styles only instead of using direct formatting without a new option for the user. The only problem I see is if the user changed the attributes of--for example--Strong Emphasis character style from bold to red and *too* results in a red string instead of bold.
Comment 6 Leandro Martín Drudi 2018-02-28 01:05:15 UTC
The ability to customize the style opens up countless possibilities for the user; making it optional (at Write level or at Document level even more) to format your documents. Replacing 4[*] steps for what it would be enough to type *too* is beneficial in time for the writer. And if the user wants to do it in certain documents or save the replacement option in the template, much more.

[*] Write the text, select it, search for the style, apply it
Comment 7 Heiko Tietze 2018-02-28 07:54:26 UTC
Leandro, what exactly is your request?

a) Extend the inbuilt auto-correct options with standardized markdown/-up

b) Make auto-correction a character style
*bold* -> <style:StrongEmphasis>bold</style>

c) Export/Copy the text as markdown
(Would be another ticket)
Comment 8 Leandro Martín Drudi 2018-02-28 15:41:11 UTC
I guess "B", because I don't know what the inner workings of the code look like (I'm just a simple user) and I have to use an online translator to understand what they say and translate from Spanish into English. But, if B applies a text style, my suggestion is related to B.
Comment 9 Leandro Martín Drudi 2018-02-28 15:42:11 UTC
Sorry, definitively is B.
Comment 10 Heiko Tietze 2018-02-28 18:06:12 UTC
Sorry that I keep insisting on the use case but I still doubt the it's a needed change. What advantage does it have to apply the style Strong Emphasis instead of just bold? Disadvantage is the hard relation to a variable: when devs change the style for some reason it requires to adopt the auto correction, and Strong Emphasis can be changed by the user. So what benefit do we get from the character style?
Comment 11 V Stuart Foote 2018-02-28 19:52:38 UTC
Believe the autocorrect mechanism can be adjusted to apply either DF as now, or alternatively a Character "Style" set by user preference. But here the DF should probably remain the default.

With Tiago S's addition of markup for Italic and Strikethrough in 2016 [1], there are now four LO edit engine "autocorrect characters" [2] that when used in start/end pairs will apply direct text formatting, when that autocorrect feature is set enabled [3][4]. 

That is the FnChgWeightUnderl autocorrect is active by default now and assigns "*", "/", "-", "_" markup these character attribute formats respectively [5]:


While "Emphasis" and "Strong Emphasis" character styles exist and could now be used and adjusted as needed, currently there are no matching character styles defined suitable to take a Strikethrough or Underline markup. Those would reqire new styles be defined and added to default templates.

[1] https://gerrit.libreoffice.org/31076

[2] https://opengrok.libreoffice.org/xref/core/editeng/source/misc/svxacorr.cxx#249

[3] Tools -> AutoCorrect -> Autocorrect Options -> Options tab: checkbox [M][T] for "Automatic *bold*, /italic/, -strikeout- and _underline_" (controlling RID_SVXSTR_BOLD_UNDER and ChgWeightUnderl)

[4] https://opengrok.libreoffice.org/xref/core/editeng/source/misc/svxacorr.cxx#1315

[5] https://opengrok.libreoffice.org/xref/core/editeng/source/misc/svxacorr.cxx#733
Comment 12 Heiko Tietze 2018-02-28 20:01:34 UTC
What is your opinion, Tiago? You added strikout and italic for 5.4 and I wonder if there was a user request.
Comment 13 Heiko Tietze 2018-03-21 20:49:34 UTC
We discussed the suggestion in the design meeting. Changing the markdown direct formatting into a character style would require first of all two additional styles. Not a big deal as well as the switch from SID_ATTR_CHAR_WEIGHT to STR_POOLCHR_HTML_STRONG (or whatever the correct command is). But the advantage is opposed by the loss of control. If users change Strong Emphasis for some reason the markdown is not working as expected anymore (consider that people try out and forget what has been done). We took also an option into consideration where the user can decide whether the current direct formatting or a character style is applied by the autocorrect function but I'm strongly against this over-engineering. So the decision is to resolve this request as WONTFIX to keep control over the convenience function.