Modul:Coordinates/kml
| Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
| Modul | Deutsch | English
|
Modul: | Dokumentation | ||
Diese Seite enthält Code in der Programmiersprache Lua. Einbindungszahl Cirrus
Dies ist die (produktive) Mutterversion eines global benutzten Lua-Moduls.
Wenn die serial-Information nicht übereinstimmt, müsste eine Kopie hiervon in das lokale Wiki geschrieben werden.
Wenn die serial-Information nicht übereinstimmt, müsste eine Kopie hiervon in das lokale Wiki geschrieben werden.
Versionsbezeichnung auf WikiData:
2018-04-02local coordinates = { suite = "Coordinates/kml",
serial = "2018-04-02",
item = 50976437 }
--[=[
Overcome a limitation in kmlexport in 2018.
There are three functions below which might be copied into an existing
[[Module:Coordinates]] ([[d:Q7348344]])
or this module might be used stand-alone.
In templates it can be used then by
{{#invoke:Coordinates|kmlTitle|Some title for geohack}}
or respectively (as is)
{{#invoke:Coordinates/kml|kmlTitle|Some title for geohack}}
]=]
coordinates.utf8max2bytes = function ( adjust )
-- Save characters > 0x7FF by simplification
-- Precondition:
-- adjust -- string to be adjusted
-- Postcondition:
-- returns string
local r = adjust
local lucky, translate = pcall( mw.loadData,
"Module:Sort/utf8max2bytes" )
if type( translate ) == "table" then
local Sort
lucky, Sort = pcall( require, "Module:Sort" )
if type( Sort ) == "table" and
type( Sort.Sort ) == "function" then
Sort = Sort.Sort()
if type( Sort ) == "table" and
type( Sort.lex ) == "function" then
local s = Sort.lex( r, translate )
if type( s ) == "string" then
r = s
end
end
end
end
return r
end -- coordinates.utf8max2bytes()
coordinates._kmlTitle = function ( adjust )
-- Hack kmlexport title as of 2018 UTF-8 limitation
-- Precondition:
-- adjust -- string to be adjusted
-- Postcondition:
-- returns string
local pattern = mw.ustring.char( 91, 0x0800, 45, 0x7FFFF, 93 )
local r = mw.text.decode( adjust, true )
r = mw.text.trim( r )
if mw.ustring.find( r, pattern ) then
r = coordinates.utf8max2bytes( r )
r = mw.ustring.gsub( r, pattern, "" )
end
if mw.text.trim( r ) == "" then
-- fall back to original string if all characters removed
r = adjust
end
return r
end -- coordinates._kmlTitle()
coordinates.kmlTitle = function ( frame )
-- #invoke to adjust kmlexport title
local r = frame.args[ 1 ]
if r and r ~= "" then
r = coordinates._kmlTitle( r )
end
return r or ""
end -- coordinates.kmlTitle
return coordinates
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.