Editing Module:Diff

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page is not enabled for semantic in-text annotations due to namespace restrictions. Details about how to enable the namespace can be found on the configuration help page.

Latest revision Your text
Line 203: Line 203:
 
   local tokens = diff(old, new, separator)
 
   local tokens = diff(old, new, separator)
 
   local root = mw.html.create('')
 
   local root = mw.html.create('')
 +
  root:wikitext(mw.getCurrentFrame():extensionTag('templatestyles', '', {src = 'Module:Diff/styles.css'}))
  
 
   local token, status
 
   local token, status
  
   local plusMinusStyle = 'width: 2%; padding: 0.25em; font-weight: bold;' ..
+
  -- Override default border-width for browsers that support them.
     'font-size: 1.25em; text-align: end;'
+
  -- Needed for RTL support; forbidden in TemplateStyles.
   local tdDivStyle = 'word-wrap: break-word; direction: ltr;'
+
   local tdSharedStyle = '-webkit-border-end-width: 1px; -webkit-border-start-width: 4px; ' ..
 +
     '-moz-border-end-width: 1px; -moz-border-start-width: 4px;'
 +
   
 +
   local is_different = false
 +
  for _, token_record in ipairs(tokens) do
 +
    if token_record[2] ~= SAME then
 +
      is_different = true
 +
      break
 +
    end
 +
  end
  
  local tdSharedStyle = 'width: 48%; border-style: solid; border-radius: 0.33em; ' ..
+
   local tr = root:tag('table'):addClass('diff'):tag('tr')
    'padding: 0.33em 0.5em; font-size: 88%; white-space: pre-wrap; border-width: 1px 1px 1px 4px; ' ..
 
    '-webkit-border-end-width: 1px; -webkit-border-start-width: 4px; ' ..
 
    '-moz-border-end-width: 1px; -moz-border-start-width: 4px;' -- these overrides default border-width for browsers supports them, needed for RTL UI on commons
 
  local insDelSharedStyle = 'padding: 0.25em 0; font-weight: bold; text-decoration: initial;'
 
 
 
 
 
   local tr = root:tag('table'):addClass('diff'):css('width', '100%'):tag('tr')
 
  
 
   tr:tag('td')
 
   tr:tag('td')
 
     :addClass('diff-marker')
 
     :addClass('diff-marker')
    :cssText(plusMinusStyle)
+
     :wikitext(is_different and '−' or ' ')
     :wikitext('−')
 
  
 
   local deleted = tr
 
   local deleted = tr
 
     :tag('td')
 
     :tag('td')
       :cssText('border-color: #ffe49c; ' .. tdSharedStyle)
+
       :cssText(tdSharedStyle)
       :addClass('diff-deletedline')
+
       :addClass(is_different and 'diff-deletedline' or 'diff-context')
 
       :tag('div')
 
       :tag('div')
        :cssText(tdDivStyle)
 
  
 
   for i, token_record in ipairs(tokens) do
 
   for i, token_record in ipairs(tokens) do
Line 237: Line 238:
 
       deleted
 
       deleted
 
         :tag('del')
 
         :tag('del')
          :cssText('background: #feeec8; ' .. insDelSharedStyle)
 
 
           :addClass('diffchange')
 
           :addClass('diffchange')
 
           :addClass('diffchange-inline')
 
           :addClass('diffchange-inline')
Line 247: Line 247:
  
 
   tr:tag('td')
 
   tr:tag('td')
     :cssText(plusMinusStyle)
+
     :addClass('diff-marker')
     :wikitext('+')
+
     :wikitext(is_different and '+' or ' ')
  
 
   local inserted = tr
 
   local inserted = tr
 
     :tag('td')
 
     :tag('td')
       :cssText('border-color: #a3d3ff; ' .. tdSharedStyle)
+
       :cssText(tdSharedStyle)
       :addClass('diff-addedline')
+
       :addClass(is_different and 'diff-addedline' or 'diff-context')
 
       :tag('div')
 
       :tag('div')
        :cssText(tdDivStyle)
 
  
 
   for i, token_record in ipairs(tokens) do
 
   for i, token_record in ipairs(tokens) do
Line 263: Line 262:
 
       inserted
 
       inserted
 
         :tag('ins')
 
         :tag('ins')
          :cssText('background: #d8ecff; ' .. insDelSharedStyle)
 
 
           :addClass('diffchange')
 
           :addClass('diffchange')
 
           :addClass('diffchange-inline')
 
           :addClass('diffchange-inline')

Please note that all contributions to Yugipedia are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 International License (see Yugipedia:Licensing for more details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)
Preview page with this template
Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above.

View this template

This page is a member of 1 hidden category: