Notepad++ ; TC - konfiguracja
Fragmenty konfiguracji Notepad++ i Total Commander
Notepad++
- “%AppData%\Notepad++\shortcuts.xml”:
<UserDefinedCommands>
<Command name="Transl. Google PL to EN" Ctrl="no" Alt="no" Shift="no" Key="0">https://translate.google.com/?sl=pl&tl=en&text=$(CURRENT_WORD)</Command>
<Command name="Transl. Bing PL to EN" Ctrl="no" Alt="no" Shift="no" Key="0">https://www.bing.com/translator/?from=pl&to=en&text=$(CURRENT_WORD)</Command>
<Command name="Transl. DeepL PL to EN" Ctrl="no" Alt="no" Shift="no" Key="0">https://www.deepl.com/translator#pl/en/$(CURRENT_WORD)</Command>
Zob. też
TotalCommander
TC menu Start. Uwaga numeracja musi być ciągła. Można albo dopisać coś na końcu sekcji, albo wstawić trochę pustych poleceń i potem je zamienić w pliku. Tutaj numeracja specjalnie od 001, żeby łatwiej było zamieniać.
-
wincmd.ini sekcja
[user]
(zwykle na końcu pliku)
menu001=-__FileDate
menu002=For selection - synchronization of dates as in the 2nd panel
cmd002=cmd
param002=/k for %%G in (%S) do py "%%FileDate%%\examples\copyFileDate.py" "%T%%~G" %%G
menu003=Date synchronization *.* (recurs.) as in the 2nd panel
cmd003=cmd
param003=/k py "%%FileDate%%\examples\copyAllDatesFromDir_recursive.py" "%T:~0,-1" "%P:~0,-1"
menu004=For selection - dates from names
cmd004=cmd
param004=/k for %%G in (%S) do py "%%FileDate%%\examples\setDateFromName.py" %%G
menu005=Dates from names - *.* (recurs.)
cmd005=cmd
param005=/k py "%%FileDate%%\examples\setDatesFromNames_recursive.py" "%P:~0,-1"
menu006=For selection - dates from metadata
cmd006=cmd
param006=/k for %%G in (%S) do py "%%FileDate%%\examples\setDateFromMetadata.py" %%G
menu007=Dates from metadata *.* (recurs.)
cmd007=cmd
param007=/k py "%%FileDate%%\examples\setDatesFromMetadata_recursive.py" "%P:~0,-1"
menu008=Date of folders on dates below it *.* (recurs.)
cmd008=cmd
param008=/k py "%%FileDate%%\examples\setFolderDates_recursive.py" "%P:~0,-1"
menu009=Date of folders on dates below it *.* (recurs.); remove empty
cmd009=cmd
param009=/k py "%%FileDate%%\examples\setFolderDates_recursive.py" "%P:~0,-1" -e
menu010=For selection - date from file in the 2nd panel
cmd010=cmd
param010=/k for %%G in (%S) do py "%%FileDate%%\examples\copyFileDate.py" "%T%M" %%G
menu011=robocopy (rekurs.) - copy OLDER dates from the 2nd panel
cmd011=cmd
param011=/k robocopy /e /xn /timfix /copy:t /dcopy:t "%T." "%P."
menu012=--
Uwaga: for %%G in (%S)
nie zadziała, gdy na liście plików jest choćby jeden, który w nazwie ma )
, a nie ma spacji, tj. nie jest objęty cudzysłowami "...."
.
Można próbować zamieniać for
na wykonanie cyklicznego skryptu, np. c:\Tools\loop.cmd
:
@echo off & set "cmd1=%~1" & SHIFT
:loop
IF .%1==. GOTO end
%cmd1% %1
SHIFT & GOTO loop
:end
pause
i wtedy np.:
menu006=For selection - dates from metadata
cmd006=c:\Tools\loop.cmd
param006="py "%%FileDate%%\examples\setDateFromMetadata.py"" %S
.
.
menu001=-__pandoc
menu002=plik -> (pl).docx
cmd002=cmd
param002=/k pandoc %N -o %N.docx -V lang=pl
menu003=plik -> (+MD.img).md
cmd003=cmd
param003=/k pandoc %N -o %N.md --verbose --extract-media=./MD.img/ --lua-filter %%AppData%%/pandoc/img_style_width.lua
menu004=plik - > 1_...MD
cmd004=cmd
param004=/k pandoc %N -o 1_%N.md --verbose --lua-filter %%AppData%%/pandoc/img_style_width.lua
menu005=plik -> HTML
cmd005=cmd
param005=/k pandoc -i %N -o %N.html --standalone -H %%appdata%%/pandoc/markdown-v.head.html -M lang=pl
menu006=plik -> 1_...HTML
cmd006=cmd
param006=/k pandoc -i %N -o 1_%N.html --embed-resources -H %%appdata%%/pandoc/markdown-v.head.html -M lang=pl
menu007=--
Wypakuj plik
markdown-v.head.html.zip
do foldera %appdata%\pandoc\
Jest to styl skopiowany z wtyczki “Markdown Viewer” dla Edge, który będzie wklejany do nagłówka HTML.
W tym pliku ZIP zawarty jest też img_style_width.lua
…
%AppData%/pandoc/img_style_width.lua - zob. https://github.com/jgm/pandoc/issues/9032 :
-- pandoc --lua-filter for markdown size attributes as {style="width:... instead of {width="...
-- written by novice pandoc user - don't rely too much on it
if FORMAT:match 'markdown' then
function Image(el)
el.attributes.style = (el.attributes.style or '') ..
' width:' .. (el.attributes.width or 'auto') ..
'; height:' .. (el.attributes.height or 'auto') .. ';'
el.attributes.width = nil
el.attributes.height = nil
return el
end
end
.
Można używać tej biblioteki do uzyskania skrajnie prostego HTML z DOCX.
Z paczki mammothH.zip
wypakuj do foldera %appdata%\mmth\
plik
mammothH.py
…
Opcjonalny plik testowy mm_test.docx
można pominąć
import os
import shutil
import argparse
import mammoth # pip install mammoth
def cli_args():
parser = argparse.ArgumentParser(
usage='python mammothH.py FILE.DOCX',
description=f'''DOCX -> HTML (mammoth + HTML head)''',)
parser.add_argument('input_file')
parser.add_argument('-o', '--output',
help='or default FILE.docx_.HTML')
parser.add_argument('-i', '--img-dir', default='',
help='directory for image files or (default) images are included inline in HTML')
parser.add_argument('-l', '--lang', default='pl-PL', help='e.g.: "pl-PL" (default)')
parser.add_argument('-s', '--td_style', nargs='+', default=(':nth-child(1)','color: DarkMagenta;', ':nth-child(3n+4)','color: Blue;'),
help='td_sel1, style1, ... e.g.: --td_style ":nth-child(1)" "color: DarkMagenta;" ":nth-child(3n+4)" "color: Blue;"' )
return parser.parse_args()
def main ():
args=cli_args() ; print(f'{args=}') #$# py 3.8+
out_suffix='._.html' #to add if not --output
output_file = args.output or f'{args.input_file}{out_suffix}' ; print(f'{output_file=}') #$#
if not args.img_dir:
convert_image = None
else:
if not os.path.exists(args.img_dir):
os.makedirs(args.img_dir) ; print(f'os.makedirs {args.img_dir}') #$#
convert_image = mammoth.images.img_element(ImageWriter(args.img_dir))
tdSel_style = list(zip(args.td_style[::2], args.td_style[1::2])) if args.td_style else [] \
; print(f'{tdSel_style=}') #$#
messages = docx_to_html(args.input_file, output_file, args.lang, convert_image, tdSel_style)
print(f'{messages=}\n.')
def docx_to_html(input_file, output_file, lang='', convert_image=None, tdSel_style=[]):
with open(input_file, "rb") as docx_file:
result = mammoth.convert_to_html(docx_file, convert_image=convert_image)
html = (f'''<!DOCTYPE html><html><head><meta charset="utf-8"/>
<style>
body {{ font-family: "Segoe UI","Noto Sans",Helvetica,Arial,sans-serif; }}
{' '.join([f'td{selector}, th{selector} {{{style}}}' for (selector,style) in tdSel_style])}
table {{border-collapse: collapse; }}
th, td {{border: 1px solid grey; font-size: 0.85em; padding:2px;}}
td p {{margin: 0px;}}
</style>
<title>{output_file}</title>
</head><body{f' lang="{lang}"' if lang else ''}>
{result.value}
</body></html>
''')
with open(output_file, "w", encoding="utf-8") as f:
f.write(html)
return result.messages
class ImageWriter(object):
# Python___\Lib\site-packages\mammoth\cli.py
def __init__(self, output_dir):
self._output_dir = output_dir
self._image_number = 1
def __call__(self, element):
extension = element.content_type.partition("/")[2]
image_filename = f"{self._image_number}.{extension}"
img_path = os.path.join(self._output_dir, image_filename)
with open(img_path, "wb") as image_dest:
with element.open() as image_source:
shutil.copyfileobj(image_source, image_dest)
self._image_number += 1
return {"src": img_path}
if __name__ == "__main__":
main ()
Wiersz cmd: python mammothH.py FILE.DOCX
…
DOCX -> HTML (mammoth + HTML head)
usage: python mammothH.py FILE.DOCX
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
or default FILE.docx_.HTML
-i IMG_DIR, --img-dir IMG_DIR
directory for image files or (default) images are included inline in HTML
-l LANG, --lang LANG e.g.: "pl-PL" (default)
-s TD_STYLE [TD_STYLE ...], --td_style TD_STYLE [TD_STYLE ...]
e.g.: --td_style ":nth-child(1)" "color: DarkMagenta;" ":nth-child(3n+4)" "color: Blue;"
.
menu001=-__mammoth docx->html
menu002=docx -> html
cmd002=cmd
param002=/k py %%AppData%%/mmth/mammothH.py %N
menu003=docx -> html (+d.img)
cmd003=cmd
param003=/k py %%AppData%%/mmth/mammothH.py %N --img-dir d.img
menu004=--
.
.
menu001=-ExifDate
menu002=ExifDate z daty pliku (zaznaczenie)
cmd002=exiftool.exe
param002=-k -P "-DateTimeOriginal<FileModifyDate" -if "$exif:DateTimeOriginal" %S
menu003="ExifDate (TWORZONE!) z daty pliku (zaznaczenie) "
cmd003=exiftool.exe
param003=-k -P "-DateTimeOriginal<FileModifyDate" %S
menu004=ExifDate do daty pliku (zaznaczenie)
cmd004=exiftool.exe
param004=-k -P "-exif:DateTimeOriginal>FileModifyDate" -if "$exif:DateTimeOriginal" %S
menu005=--
.
.
- mklink
menu001=echo mklink /d (1 folder w drugim oknie)
cmd001=cmd
param001=/k echo "::copy&AdmRun:: cd %P && mklink /d %M %T%M ::"