モジュール‐ノート:Val

ページのコンテンツが他言語でサポートされていません。

リンク時の下線[編集]

{{Val}}を含む箇所にリンクを付加すると、{{Val}}が挿入した3桁毎のスペースの部分に(リンクを示す)下線が付かない現象が起きます。

これは{{Val}}がスペースを

  • 1<span style="margin-left:.25em">234</span><span style="margin-left:.25em">567</span>

の様に、<span style="margin-left:.25em">で確保しているのが原因と思われます。 解決策をWikipedia:井戸端で伺った処、利用者:Waiesuさんから、

例えば、右から4, 7, 10, ...ケタ目を<span style="letter-spacing:.25em;"></span>で囲うようにすればいいのではないでしょう か(1234567こんな感じ)。

と云う御提案を頂きました。これに沿う形にModule:Valの変更を行う事を提案致します。--Polyester会話2016年5月8日 (日) 11:02 (UTC)[返信]

賛成 賛成します。ソースはこんな感じになるでしょうか。詳しい方おりましたらコメントお願いします。
現在 変更案
local function delimit(sign, numstr, fmt)
	-- Return sign and numstr (unsigned digits or '.' only) after formatting.
	-- Four-digit integers are not formatted with gaps.
	fmt = (fmt or ''):lower()
	if fmt == 'none' or (fmt == '' and #numstr == 4 and numstr:match('^%d+$')) then
		return sign .. numstr
	end
	-- Group number by integer and decimal parts.
	-- If there is no decimal part, delimit_groups returns only one table.
	local ipart, dpart = delimit_groups(numstr)
	local result
	if fmt == 'commas' then
		result = sign .. table.concat(ipart, ',')
		if dpart then
			result = result .. '.' .. table.concat(dpart)
		end
	else
		-- Delimit with a small gap by default.
		local groups = {}
		groups[1] = table.remove(ipart, 1)
		for _, v in ipairs(ipart) do
			table.insert(groups, '<span style="margin-left:.25em">' .. v .. '</span>')
		end
		if dpart then
			table.insert(groups, '.' .. (table.remove(dpart, 1) or ''))
			for _, v in ipairs(dpart) do
				table.insert(groups, '<span style="margin-left:.25em">' .. v .. '</span>')
			end
		end
		result = sign .. table.concat(groups)
	end
	return result
end
local function delimit(sign, numstr, fmt)
	-- Return sign and numstr (unsigned digits or '.' only) after formatting.
	-- Four-digit integers are not formatted with gaps.
	fmt = (fmt or ''):lower()
	if fmt == 'none' or (fmt == '' and #numstr == 4 and numstr:match('^%d+$')) then
		return sign .. numstr
	end
	-- Group number by integer and decimal parts.
	-- If there is no decimal part, delimit_groups returns only one table.
	local ipart, dpart = delimit_groups(numstr)
	local result
	if fmt == 'commas' then
		result = sign .. table.concat(ipart, ',')
		if dpart then
			result = result .. '.' .. table.concat(dpart)
		end
	else
		-- Delimit with a small gap by default.
		local groups = {}
		for _, v in ipairs(ipart) do
			v = string.gsub(v, '(%d*)(%d)', '%1<span style="letter%-spacing:%.25em">%2</span>')
			table.insert(groups, v)
		end
		if dpart then
			table.insert(groups, '.' .. (table.remove(dpart, 1) or ''))
			for _, v in ipairs(dpart) do
				v = string.gsub(v, '(%d*)(%d)', '%1<span style="letter%-spacing:%.25em">%2</span>')
				table.insert(groups, v)
			end
		end
		groups[#groups] = string.gsub(groups[#groups], '</?span.->', '')
		result = sign .. table.concat(groups)
	end
	return result
end
--Waiesu会話2016年5月8日 (日) 13:13 (UTC)[返信]
コメントサンドボックステストケースを作成し、サンドボックスに上の差分を適用してみました。正常に動作しているように見えますがもうちょっとテストケースを増やす必要はあるかもしれません。 -- ktns会話2016年5月8日 (日) 13:48 (UTC)[返信]
不確かさを指定すると不確かさの前の±記号の前後のスペースに下線が引かれないようです。 -- ktns会話2016年5月8日 (日) 14:32 (UTC)[返信]
賛成 すみません、よろしく御願いします。--Polyester会話2016年6月18日 (土) 02:01 (UTC)[返信]

数値と単位との間の空白[編集]

現状では数値と単位との間に letter-spacing と空白文字が両方入ってしまい(例: 50 dB)、空白が広すぎるように感じます。どちらかのみにしたほうが良いのではないでしょうか?個人的には letter-spacing のみでよいように思います(テキストをコピーした際に空白が入らなくはなりますが)。 -- ktns会話2017年10月20日 (金) 01:53 (UTC)[返信]

数値と範囲記号の間に letter-spacing が入ってしまうことにも気付きました(例: 10–20)。これもあわせて修正するためには仮数部の最下位桁に letter-spacing をつけないよう修正し、単位との間に ' ' ではなく ' ' を入れるのがよいでしょうか(すでに class="nowrap" の span 要素で囲われているので改行されてしまう心配はないはずです)。 -- ktns会話2017年10月22日 (日) 02:09 (UTC)[返信]
コメント Module:Val/sandboxを、単位/範囲記号の前ではletter-spacingを適用しないように変更してみました。(スペース記号はそのままにしています。)Template:Val/testcasesでは改善されていますが、抜けがあるかもしれないので、確認とご意見をお願いいたします。--Waiesu会話2017年10月29日 (日) 03:31 (UTC)[返信]

単位追加[編集]

重量キログラム毎平方センチメートル(kgf/cm2)をulで使える様に追加して欲しいです。--Polyester会話2018年5月26日 (土) 13:28 (UTC)[返信]

モジュール:Val/units に追加してみました。kgf/cm2 のように使えると思います。 -- ktns会話2018年5月27日 (日) 12:49 (UTC)[返信]

(一旦戻します)「平方アンペア」(A2)をA2として、uやupで使える様に追加して欲しいです(磁気定数の単位がニュートン毎平方アンペアなので)。--Polyester会話2022年10月23日 (日) 10:12 (UTC)[返信]

既にN.A-2で在りましたね。お騒がせしました。--Polyester会話2022年10月23日 (日) 10:24 (UTC)[返信]

display:noneからdata-sort-valueへの置換提案[編集]

「アボガドロ定数」でGoogle検索すると、

アボガドロ定数(アボガドロていすう、英: Avogadro constant )とは、物質量 7000100000000000000♤1 mol を構成する粒子(分子、原子、イオンなど)の個数を示す定数である。

のようにソートキー部分が本文として表示されてしまいます。これはソートキー部分が

<span style="display:none" class="sortkey">7000100000000000000♠</span>

と指定されているのが原因なので、テーブル内でのソートキーに必要な文字列であれば

<span data-sort-value="7000100000000000000♠"></span>

に置き換えが可能かと思われますがいかがでしょうか?--111.239.160.68 2020年10月23日 (金) 23:16 (UTC)[返信]

小数点以下4桁だけ例外?[編集]

NIST Guide to the SI に拠ると、

10.5.3 Grouping digits

Because the comma is widely used as the decimal marker outside the United States, it should not be used to separate digits into groups of three. Instead, digits should be separated into groups of three, counting from the decimal marker towards the left and right, by the use of a thin, fixed space. However, this practice is not usually followed for numbers having only four digits on either side of the decimal marker except when uniformity in a table is desired.

https://www.nist.gov/pml/special-publication-811/nist-guide-si-chapter-10-more-printing-and-using-symbols-and-numbers

だそうで、4桁の場合だけ例外としてもいいらしいのですけど、一歩踏み込んだ英語版に倣って、小数点以下7桁、10桁、…、(3の整数倍+1桁)の場合も、(4桁の場合と同様に)末位桁のその一つ上位の桁の間はスペースを空けない方がいいのではないでしょうか?--Polyester会話2022年11月13日 (日) 01:44 (UTC)[返信]