Modified regular expressions for support wrapping in tags.#1195
Modified regular expressions for support wrapping in tags.#1195icambron merged 3 commits intomoment:developfrom
Conversation
|
Can you explain this a bit more? |
|
This doesn't look such a good idea to me, regex matching of HTML elements is notoriously error prone. I would say it would be better for the end user to perform their own stripping before passing tokens to moment, they are then responsible for their mistakes. |
|
The patch for Russian language. This regular expression is only checks what grammatical case must be used. puts But if I need to use html-tags, escaped symbols or anything else old regular expression doesn't work, because puts date in nominative case (but must be accusative case) My patch can fix this problem. puts |
|
@Xotic750 - I believe @jarosluv is referring to formatting, not parsing, e.g.: > moment().lang('ru').format('DD [<b>]MMMM[</b>]')
'21 <b>октябрь</b>'Where Russian uses special rules to determine how to format the month. But I do have some concerns:
|
|
@icambron Yes, I realised my mistake after the further explanation and a look at the change made. It was simply my bad assumption from reading the initial post. :) |
|
Sorry for confusion. Yes, I really referring to formatting. Let's analyze this situation step by step. What is required? What we have now? > moment().lang('ru').format('DD MMMM')
"22 октября" // true, accusative caseBut if we want to add any symbols between DD and MMMM, RE doesn't work, because puts month name in nominative case (but must be accusative case): > moment().lang('ru').format('DD [<b>]MMMM[</b>]')
"22 <b>октябрь</b>" // false, nominative caseWhat I suggest? The best solution. > moment().lang('ru').format('DD MMMM')
"22 октября" // true, accusative case
> moment().lang('ru').format('DD [<b>]MMMM[</b>]')
"22 <b>октября</b>" // true, accusative case
> moment().lang('ru').format('DD[-й день] MMMM')
"22-й день октября" // true, accusative case
> moment().lang('ru').format('DD[-й день], месяц MMMM')
"22-й день, месяц октябрь" // true, nominative case
> moment().lang('ru').format('DD, MMMM')
"22, октябрь" // true, nominative caseThere is new RE: |
|
@jarosluv That's fine with me. Want to edit the pull request accordingly and add some tests? |
|
@icambron Sure :) |
…ses in Russian language. Escaped symbols doesn't affect the correct format of grammatical cases in pattern 'D[oD]? MMMM?'.
Conflicts: lang/ru.js
|
@icambron Is it alright? |
|
Yup, looks good! |
Modified regular expressions for support wrapping in tags.
|
@Oire I suppose that makes sense |
If I want to wrap day or month in html-tags
old regular expressions don't work.