@@ -4,12 +4,10 @@ const path = require('path')
44const cheerio = require ( 'cheerio' )
55const patterns = require ( './patterns' )
66const getMapTopicContent = require ( './get-map-topic-content' )
7- const rewriteAssetPathsToS3 = require ( './rewrite-asset-paths-to-s3' )
87const getApplicableVersions = require ( './get-applicable-versions' )
98const encodeBracketedParentheses = require ( './encode-bracketed-parentheses' )
109const generateRedirectsForPermalinks = require ( './redirects/permalinks' )
1110const getEnglishHeadings = require ( './get-english-headings' )
12- const useEnglishHeadings = require ( './use-english-headings' )
1311const getTocItems = require ( './get-toc-items' )
1412const pathUtils = require ( './path-utils' )
1513const Permalink = require ( './permalink' )
@@ -154,6 +152,12 @@ class Page {
154152 this . markdown = await this . getMarkdown ( )
155153 }
156154
155+ // use English IDs/anchors for translated headings, so links don't break (see #8572)
156+ if ( this . languageCode !== 'en' ) {
157+ const englishHeadings = getEnglishHeadings ( this , context . pages )
158+ context . englishHeadings = englishHeadings
159+ }
160+
157161 this . intro = await renderContent ( this . rawIntro , context )
158162 this . introPlainText = await renderContent ( this . rawIntro , context , { textOnly : true } )
159163 this . title = await renderContent ( this . rawTitle , context , { textOnly : true , encodeEntities : true } )
@@ -185,6 +189,7 @@ class Page {
185189 } ) )
186190 }
187191
192+ context . relativePath = this . relativePath
188193 const html = await renderContent ( markdown , context )
189194
190195 // product frontmatter may contain liquid
@@ -227,29 +232,14 @@ class Page {
227232 } )
228233 }
229234
230- const $ = cheerio . load ( html )
231-
232235 // set a flag so layout knows whether to render a mac/windows/linux switcher element
233- this . includesPlatformSpecificContent = $ ( '[class^="platform-"], .mac, .windows, .linux' ) . length > 0
234-
235- // rewrite asset paths to s3 if it's a dotcom article on any GHE version
236- // or if it's an enterprise article on any GHE version EXCEPT latest version
237- rewriteAssetPathsToS3 ( $ , context . currentVersion , this . relativePath )
238-
239- // use English IDs/anchors for translated headings, so links don't break (see #8572)
240- if ( this . languageCode !== 'en' ) {
241- const englishHeadings = getEnglishHeadings ( this , context . pages )
242- if ( englishHeadings ) useEnglishHeadings ( $ , englishHeadings )
243- }
244-
245- // wrap ordered list images in a container div
246- $ ( 'ol > li img' ) . each ( ( i , el ) => {
247- $ ( el ) . wrap ( '<div class="procedural-image-wrapper" />' )
248- } )
249-
250- const cleanedHTML = $ ( 'body' ) . html ( )
236+ this . includesPlatformSpecificContent = (
237+ html . includes ( 'extended-markdown mac' ) ||
238+ html . includes ( 'extended-markdown windows' ) ||
239+ html . includes ( 'extended-markdown linux' )
240+ )
251241
252- return cleanedHTML
242+ return html
253243 }
254244
255245 // Allow other modules (like custom liquid tags) to make one-off requests
0 commit comments