简体   繁体   中英

How to change the media player position using Lua generated wiki code?

This Lua code:

function p.pron_reg(frame)
local cette_page = mw.title.getCurrentTitle()
-- récup des params & valeurs par défaut
local args = frame:getParent().args
local pays = args[1] or '<small>(Région à préciser)</small>'
local text_api = args[2]
local code_lang = args[3] or args["lang"]
local fic_audio = args["audio"]
local title = args["title"] or cette_page.text

-- Génération du wikicode
local txt = pays .. ' : '
if ((text_api) or (fic_audio)) then
    if (fic_audio and fic_audio ~= '') then
        txt = txt .. 'auscultare « ' .. title
        if (text_api) then
            txt = txt .. ' ' .. p.lua_pron(text_api,code_lang,'[]')
        end
        txt = txt .. ' » [[File:' .. fic_audio .. ']]'
    else
        txt = txt .. p.lua_pron(text_api,code_lang,'[]')
    end
else
    txt = txt .. '<small>merci de préciser une prononciation phonétique ou un fichier audio (voir la [[Modèle:écouter|notice]])</small>'
end
return txt
end

create an template for IPA and audio pronunciations. Is there any chance to move the audio player next to the IPA pronunciation (before » ) just like in the picture ( link )

Wikitext generated with Lua code is parsed the same way as wikitext that you just enter yourself, so the problem here doesn't actually have anything to do with Lua. Instead, it has to do with the HTML generated by the wikitext you are outputting. To display the media player inline, you need to use display: inline-block; in the CSS. You can do that with the following wikitext without having to edit any of your wiki's CSS files:

<div>Foo <div style="display: inline-block">[[File:Example.ogg]]</div></div>

If you make your Lua module output something like that, that should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM