# Highlight-based quoting ruby text messes up formatting

**URL:** https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282
**Category:** Feature
**Created:** [August 8, 2019, 9:02pm UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282 "2019-08-08T21:02:57Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [August 8, 2019, 9:02pm UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/1 "2019-08-08T21:02:57Z")

</div>

Continuing the discussion from [Inline language markup? (language learning site)](https://meta.discourse.org/t/inline-language-markup-language-learning-site/63582/21):

Not sure if this would be considered a bug or a request for enhancement. Basically, when you quote ruby text, the quote doesn’t show up correctly. For example:

日に本ほん語ご

If you quote this you’ll get something like:  
日に本ほん語

Could this be updated in some way so the quote includes the ruby tags for proper formatting? Or is that consider an “advanced” quote that will only work on full post quoting?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 9, 2019, 3:56am UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/2 "2019-08-09T03:56:54Z")

</div>

Yeah I would like us to implement this it should be straightforward … our JS implementation of HTML → Markdown has a minor oversight.

@vinothkannans can you add to your list?

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [August 9, 2019, 5:15am UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/4 "2019-08-09T05:15:34Z")

</div>

Awesome. To add one thing, I noticed that often furigana (`rt` tagged text) above the last character won’t get highlighted and therefore doesn’t get quoted (but it should). It probably won’t be a big deal to handle since that’s all within the last `ruby` tag anyway, but it’s something to keep in mind when implementing.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 9, 2019, 5:16am UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/5 "2019-08-09T05:16:38Z")

</div>

OK, just keep in mind, this is not a major priority for us but I think we should get it done over the next month or two. It is assigned out.

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [December 4, 2019, 1:07am UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/6 "2019-12-04T01:07:28Z")

</div>

Any chance this will be worked on soon-ish? 🙂

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 4, 2019, 3:50am UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/7 "2019-12-04T03:50:12Z")

</div>

Sure, I already bumped it up in my to-do list for this week.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 5, 2019, 3:50pm UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/8 "2019-12-05T15:50:47Z")

</div>

It’s done. The below commit should resolve this issue.

[https://github.com/discourse/discourse/commit/aa5d4e9f6ee179a554d186aaab30da367f95557a](https://github.com/discourse/discourse/commit/aa5d4e9f6ee179a554d186aaab30da367f95557a)

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [December 5, 2019, 5:59pm UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/9 "2019-12-05T17:59:47Z")

</div>

It might be good to keep all the ruby-related tags that have been [whitelisted](https://github.com/discourse/discourse/blob/9845963105c03ab50b7443667e0e1a21855e125a/app/assets/javascripts/pretty-text/white-lister.js.es6#L196-L202), even though `rb` and `rp` aren’t used as much anymore. `rp` is used for legacy support for old browser though, so maybe not particularly relevant for Discourse. No big deal one way or the other, just thought I should mention.

EDIT:  
More importantly, when I test this on the word in my OP (and _only_ that word) it misses the surrounding `ruby` tags, so it doesn’t format the text as expected. When I highlight text on either side it before quoting, includes the `ruby` tag, but that workaround wouldn’t work if the word was the first or last part of the post. Is there anything that can be done to make sure it includes the `ruby` tags?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 5, 2019, 6:17pm UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/10 "2019-12-05T18:17:11Z")

</div>

Sure, I’ll whitelist those tags if needed. Also, it is easy to do in a PR contribution.

> [@seanblue](#):
>
> More importantly, when I test this on the word in my OP (and _only_ that word) it misses the surrounding `ruby` tags,

It is a problem with the browser level UX in copy-paste functionality. We can’t do much here.

---

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [December 5, 2019, 6:43pm UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/11 "2019-12-05T18:43:39Z")

</div>

> [@vinothkannans](#):
>
> Also, it is easy to do in a PR contribution.

I’ll get a Discourse dev environment set up one of these days. 😅

> [@vinothkannans](#):
>
> It is a problem with the browser level UX in copy-paste functionality. We can’t do much here.

Understood. Worst case scenario I can do a full post quote to get the proper HTML for those cases. This is still a huge improvement. Thanks!

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [January 4, 2020, 12:42pm UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/12 "2020-01-04T12:42:45Z")

</div>

The `rb` and `rp` tags are now whitelisted.

[https://github.com/discourse/discourse/commit/7dbde18f025dfa03103dbc75a647d28ed8752e02](https://github.com/discourse/discourse/commit/7dbde18f025dfa03103dbc75a647d28ed8752e02)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 7, 2020, 7:00am UTC](https://meta.discourse.org/t/highlight-based-quoting-ruby-text-messes-up-formatting/125282/13 "2020-01-07T07:00:02Z")

</div>

This topic was automatically closed after 25 hours. New replies are no longer allowed.
