From 65b888a52088b81b5fa674fbee89fe220f84fc9f Mon Sep 17 00:00:00 2001 From: Fomafix Date: Fri, 29 May 2015 17:07:55 +0000 Subject: [PATCH] Add HTML attributes lang and dir to toctitle The toctitle is in user interface language. This change add the HTML attributes lang and dir to the toctitle. This allows to copy (a part of) the rendered HTML to a word processing and the language for spell checking has the right language. Change-Id: I17730869f81744560672d7d0acb67ced71e69c4e --- includes/Linker.php | 7 +- tests/parser/parserTests.txt | 64 +++++++++---------- .../resources/mediawiki/mediawiki.toc.test.js | 2 +- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index 48be3bfe7a..84e3103c65 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1595,7 +1595,12 @@ class Linker { $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped(); return '
' - . '

' . $title . "

\n" + . Html::openElement( 'div', [ + 'class' => 'toctitle', + 'lang' => $lang->getHtmlCode(), + 'dir' => $lang->getDir(), + ] ) + . '

' . $title . "

\n" . $toc . "\n\n"; } diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 72ee550109..840c74dbb9 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -16578,7 +16578,7 @@ Section headings with TOC Some text ===Another headline=== !! html -

Contents

+

Contents

  • 1 Headline 1
      @@ -16621,7 +16621,7 @@ __FORCETOC__ == Headline 2 == == Headline == !! html/php -

      Contents

      +

      Contents

      • 1 Headline 2
      • 2 Headline
      • @@ -16655,7 +16655,7 @@ parsoid=wt2html ========= Level 9 Heading========= ========== Level 10 Heading========== !! html/php -

        Contents

        +

        Contents

        • 1 Level 1 Heading
            @@ -16719,7 +16719,7 @@ TOC regression (T11764) == title 2 == === title 2.1 === !! html -

            Contents

            +

            Contents

            • 1 title 1
                @@ -16754,7 +16754,7 @@ TOC for heading containing (T96153) __FORCETOC__ ==New title== !! html/php -

                Contents

                +

                Contents

                @@ -16776,7 +16776,7 @@ wgMaxTocLevel=3 == title 2 == === title 2.1 === !! html -

                Contents

                +

                Contents

                • 1 title 1
                    @@ -16812,7 +16812,7 @@ wgMaxTocLevel=3 ====Section 1.1.1.1==== ==Section 2== !! html -

                    Contents

                    +

                    Contents

                    • 1 Section 1
                        @@ -16905,7 +16905,7 @@ __TOC__ === title 1.1 === == title 2 == !! html -

                        Contents

                        +

                        Contents

                        • 1 title 1
                            @@ -16981,7 +16981,7 @@ section 5 !! html/php

                            The tooltips shall not show entities to the user (ie. be double escaped)

                            -

                            Contents

                            +

                            Contents

                            • 1 text > text
                            • 2 text < text
                            • @@ -17057,7 +17057,7 @@ section 6 !! html/php

                              Id should not contain + for spaces

                              -

                              Contents

                              +

                              Contents

                              • 1 Space between Text
                              • 2 Space-Entity between Text
                              • @@ -17133,7 +17133,7 @@ parsoid=wt2html,wt2wt,html2html =''italic'' heading== ==''italic'' heading= !! html/php -

                                Contents

                                +

                                Contents

                                • 1 foo=
                                • 2 =foo
                                • @@ -17168,7 +17168,7 @@ HTML headers vs TOC (T25393) == Header 2.2 == __NOEDITSECTION__ !! html/php -

                                  Contents

                                  +

                                  Contents

                                  • 1 Header 1
                                      @@ -19081,7 +19081,7 @@ Fuzz testing: Parser14 http://__TOC__ !! html/php

                                      onmouseover=[edit]

                                      -http://

                                      Contents

                                      +http://

                                      Contents

                                      @@ -19092,7 +19092,7 @@ http://

                                      Contents

                                      onmouseover=[edit]

                                      http://

                                      -
                                      +

                                      Contents

                                        @@ -21608,7 +21608,7 @@ Out-of-order TOC heading levels =====5===== ==2== !! html -

                                        Contents

                                        +

                                        Contents

                                        • 1 2
                                            @@ -24242,7 +24242,7 @@ title=[[Main Page]] __TOC__ == ''Lost'' episodes == !! html/php -

                                            Contents

                                            +

                                            Contents

                                            @@ -24263,7 +24263,7 @@ title=[[Main Page]] __TOC__ == '''should be bold''' then normal text == !! html/php -

                                            Contents

                                            +

                                            Contents

                                            @@ -24284,7 +24284,7 @@ title=[[Main Page]] __TOC__ == Image [[Image:foobar.jpg]] == !! html/php -

                                            Contents

                                            +

                                            Contents

                                            @@ -24305,7 +24305,7 @@ title=[[Main Page]] __TOC__ ==
                                            Quote
                                            == !! html/php -

                                            Contents

                                            +

                                            Contents

                                            @@ -24316,7 +24316,7 @@ __TOC__ !! html/php+tidy

                                            -
                                            +

                                            Contents

                                              @@ -24346,7 +24346,7 @@ __TOC__ Hanc marginis exiguitas non caperet. QED !! html/php -

                                              Contents

                                              +

                                              Contents

                                              @@ -24371,7 +24371,7 @@ __TOC__ == Foo
                                              Bar
                                              == !! html/php -

                                              Contents

                                              +

                                              Contents

                                              • 1 Foo Bar
                                              • 2 Foo Bar
                                              • @@ -24384,7 +24384,7 @@ __TOC__ !! html/php+tidy

                                                -
                                                +

                                                Contents

                                                  @@ -24418,7 +24418,7 @@ __TOC__ == Evilbye == !! html/php -

                                                  Contents

                                                  +

                                                  Contents

                                                  • 1 Hello
                                                  • 2 b">Evilbye
                                                  • @@ -24449,7 +24449,7 @@ __TOC__ == Attributes after dir on these span tags must be deleted from the TOC == !! html/php -

                                                    Contents

                                                    +

                                                    Contents

                                                    • 1 C++
                                                    • 2 זבנג!
                                                    • @@ -24480,7 +24480,7 @@ T74884: bdi element in ToC __TOC__ == test == !! html/php -

                                                      Contents

                                                      +

                                                      Contents

                                                      @@ -24499,7 +24499,7 @@ T35715: s/strike element in ToC __TOC__ == test test test == !! html/php -

                                                      Contents

                                                      +

                                                      Contents

                                                      @@ -24521,7 +24521,7 @@ Empty

                                                      tag in TOC, removed by Sanitizer (T92892) __TOC__ == x == !! html/php -

                                                      Contents

                                                      +

                                                      Contents

                                                      @@ -24532,7 +24532,7 @@ __TOC__ !! html/php+tidy

                                                      -
                                                      +

                                                      Contents

                                                        @@ -29955,7 +29955,7 @@ wgFragmentMode=[ 'html5', 'legacy' ] [[#啤酒]] [[#%E5%95%A4%E9%85%92]] !! html/php -

                                                        Contents

                                                        +

                                                        Contents

                                                        • 1 Foo bar
                                                        • 2 foo Bar
                                                        • @@ -30021,7 +30021,7 @@ wgFragmentMode=[ 'legacy', 'html5' ] [[#啤酒]] [[#%E5%95%A4%E9%85%92]] !! html/php -

                                                          Contents

                                                          +

                                                          Contents

                                                          • 1 Foo bar
                                                          • 2 foo Bar
                                                          • @@ -30069,7 +30069,7 @@ wgFragmentMode=[ 'html5' ] [[#啤酒]] [[#%E5%95%A4%E9%85%92]] !! html/php -

                                                            Contents

                                                            +

                                                            Contents

                                                            • 1 Foo bar
                                                            • 2 foo Bar
                                                            • diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js index b20b68f5d6..6a1b83cf12 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js @@ -12,7 +12,7 @@ assert.strictEqual( $( '.toc' ).length, 0, 'There is no table of contents on the page at the beginning' ); tocHtml = '
                                                              ' + - '
                                                              ' + + '
                                                              ' + '

                                                              Contents

                                                              ' + '
                                                              ' + '
                                                              ' + -- 2.20.1