Word: Clean copy from lists, remove bullet points and leading numbers (v11.0.3)

Another problem with nested bullet lists in the public.utf8-plain-text component of an MS Word clipboard, is that sub-lists are no more indented than their parent items.

If, for any reason, you need to preserve indentation, while removing bullet and numbering prefixes, for example copying an MS Word nested bullet list like:

Screenshot 2025-04-02 at 1.29.13 pm

to tab-indented plain text:

MS Word bullet outline
Alpha
	Delta
	Epsilon
		Theta
			Lambda
			Mu
			Nu
		Iota
		Kappa
	Zeta
Beta
Gamma

Then you can try something like the macro below, which needs you to have, somewhere in an active KM Group, Ver 0.6 or above of the Filtering XML with XQuery Subroutine

Macro using that subroutine:

MS Word Bullet Nest copied as Indented Text.kmmacros (12 KB)


XQuery over public.html component of MS Word clipboard:

for $p in //p
return if (contains($p/@style, "level")) then
	(: LEVEL as integer :)
	let $level := 
		for $t in tokenize($p/@style, ";") 
		where starts-with($t, "mso-list")
		return xs:integer(substring-after(tokenize($t, " ")[2], "level"))

	(: One TAB for each level above 1:)
	return concat(
		string-join((for $i in 2 to $level return "\t"),""),

		(: SECOND span only – first is bullet prefix :)
		$p//span[matches(., "\p{L}")]/text()[2]
	)
else
	string($p)