Unable to format Markdown with full-width spaces
Describe the bug
An error occurs when formatting an markdown file that has a line with only spaces directly under certain keywords.
The error message is
% mdformat hoge.md
Error: Could not format
"/somepath/hoge.md".
The formatted Markdown renders to different HTML than the input Markdown. This
is likely a bug in mdformat. Please create an issue report here, including the
input Markdown: https://github.com/executablebooks/mdformat/issues
Reproduce the bug
- Prepare the following Markdown file. The file below has a full-width space below the line with the heading keyword.
# hoge
- Format this with
mdformat hoge.md
List your environment
% python --version
Python 3.9.13
% pip list
Package Version
------------------------------------------------- -------
asgiref 3.4.1
cffi 1.15.0
colour 0.1.5
cryptography 36.0.0
distlib 0.3.4
Django 4.0
filelock 3.7.1
importlib-metadata 4.12.0
markdown-it-py 2.1.0
mdformat 0.7.14
mdurl 0.1.1
norminette 3.3.2
packaging 21.3
pip 22.1.2
platformdirs 2.5.2
playsound 1.3.0
pluggy 1.0.0
powerline-shell 0.7.0
protobuf 3.19.4
push-swap-gui 1.1
py 1.11.0
pycparser 2.21
pygame 2.1.2
PyJWT 2.3.0
pyobjc 8.4.1
pyobjc-core 8.4.1
pyobjc-framework-Accessibility 8.4.1
pyobjc-framework-Accounts 8.4.1
pyobjc-framework-AddressBook 8.4.1
pyobjc-framework-AdServices 8.4.1
pyobjc-framework-AdSupport 8.4.1
pyobjc-framework-AppleScriptKit 8.4.1
pyobjc-framework-AppleScriptObjC 8.4.1
pyobjc-framework-ApplicationServices 8.4.1
pyobjc-framework-AppTrackingTransparency 8.4.1
pyobjc-framework-AudioVideoBridging 8.4.1
pyobjc-framework-AuthenticationServices 8.4.1
pyobjc-framework-AutomaticAssessmentConfiguration 8.4.1
pyobjc-framework-Automator 8.4.1
pyobjc-framework-AVFoundation 8.4.1
pyobjc-framework-AVKit 8.4.1
pyobjc-framework-BusinessChat 8.4.1
pyobjc-framework-CalendarStore 8.4.1
pyobjc-framework-CallKit 8.4.1
pyobjc-framework-CFNetwork 8.4.1
pyobjc-framework-ClassKit 8.4.1
pyobjc-framework-CloudKit 8.4.1
pyobjc-framework-Cocoa 8.4.1
pyobjc-framework-Collaboration 8.4.1
pyobjc-framework-ColorSync 8.4.1
pyobjc-framework-Contacts 8.4.1
pyobjc-framework-ContactsUI 8.4.1
pyobjc-framework-CoreAudio 8.4.1
pyobjc-framework-CoreAudioKit 8.4.1
pyobjc-framework-CoreBluetooth 8.4.1
pyobjc-framework-CoreData 8.4.1
pyobjc-framework-CoreHaptics 8.4.1
pyobjc-framework-CoreLocation 8.4.1
pyobjc-framework-CoreMedia 8.4.1
pyobjc-framework-CoreMediaIO 8.4.1
pyobjc-framework-CoreMIDI 8.4.1
pyobjc-framework-CoreML 8.4.1
pyobjc-framework-CoreMotion 8.4.1
pyobjc-framework-CoreServices 8.4.1
pyobjc-framework-CoreSpotlight 8.4.1
pyobjc-framework-CoreText 8.4.1
pyobjc-framework-CoreWLAN 8.4.1
pyobjc-framework-CryptoTokenKit 8.4.1
pyobjc-framework-DataDetection 8.4.1
pyobjc-framework-DeviceCheck 8.4.1
pyobjc-framework-DictionaryServices 8.4.1
pyobjc-framework-DiscRecording 8.4.1
pyobjc-framework-DiscRecordingUI 8.4.1
pyobjc-framework-DiskArbitration 8.4.1
pyobjc-framework-DVDPlayback 8.4.1
pyobjc-framework-EventKit 8.4.1
pyobjc-framework-ExceptionHandling 8.4.1
pyobjc-framework-ExecutionPolicy 8.4.1
pyobjc-framework-ExternalAccessory 8.4.1
pyobjc-framework-FileProvider 8.4.1
pyobjc-framework-FileProviderUI 8.4.1
pyobjc-framework-FinderSync 8.4.1
pyobjc-framework-FSEvents 8.4.1
pyobjc-framework-GameCenter 8.4.1
pyobjc-framework-GameController 8.4.1
pyobjc-framework-GameKit 8.4.1
pyobjc-framework-GameplayKit 8.4.1
pyobjc-framework-ImageCaptureCore 8.4.1
pyobjc-framework-IMServicePlugIn 8.4.1
pyobjc-framework-InputMethodKit 8.4.1
pyobjc-framework-InstallerPlugins 8.4.1
pyobjc-framework-InstantMessage 8.4.1
pyobjc-framework-Intents 8.4.1
pyobjc-framework-IntentsUI 8.4.1
pyobjc-framework-IOSurface 8.4.1
pyobjc-framework-iTunesLibrary 8.4.1
pyobjc-framework-KernelManagement 8.4.1
pyobjc-framework-LatentSemanticMapping 8.4.1
pyobjc-framework-LaunchServices 8.4.1
pyobjc-framework-libdispatch 8.4.1
pyobjc-framework-LinkPresentation 8.4.1
pyobjc-framework-LocalAuthentication 8.4.1
pyobjc-framework-LocalAuthenticationEmbeddedUI 8.4.1
pyobjc-framework-MailKit 8.4.1
pyobjc-framework-MapKit 8.4.1
pyobjc-framework-MediaAccessibility 8.4.1
pyobjc-framework-MediaLibrary 8.4.1
pyobjc-framework-MediaPlayer 8.4.1
pyobjc-framework-MediaToolbox 8.4.1
pyobjc-framework-Metal 8.4.1
pyobjc-framework-MetalKit 8.4.1
pyobjc-framework-MetalPerformanceShaders 8.4.1
pyobjc-framework-MetalPerformanceShadersGraph 8.4.1
pyobjc-framework-MetricKit 8.4.1
pyobjc-framework-MLCompute 8.4.1
pyobjc-framework-ModelIO 8.4.1
pyobjc-framework-MultipeerConnectivity 8.4.1
pyobjc-framework-NaturalLanguage 8.4.1
pyobjc-framework-NetFS 8.4.1
pyobjc-framework-Network 8.4.1
pyobjc-framework-NetworkExtension 8.4.1
pyobjc-framework-NotificationCenter 8.4.1
pyobjc-framework-OpenDirectory 8.4.1
pyobjc-framework-OSAKit 8.4.1
pyobjc-framework-OSLog 8.4.1
pyobjc-framework-PassKit 8.4.1
pyobjc-framework-PencilKit 8.4.1
pyobjc-framework-Photos 8.4.1
pyobjc-framework-PhotosUI 8.4.1
pyobjc-framework-PreferencePanes 8.4.1
pyobjc-framework-PushKit 8.4.1
pyobjc-framework-Quartz 8.4.1
pyobjc-framework-QuickLookThumbnailing 8.4.1
pyobjc-framework-ReplayKit 8.4.1
pyobjc-framework-SafariServices 8.4.1
pyobjc-framework-SceneKit 8.4.1
pyobjc-framework-ScreenCaptureKit 8.4.1
pyobjc-framework-ScreenSaver 8.4.1
pyobjc-framework-ScreenTime 8.4.1
pyobjc-framework-ScriptingBridge 8.4.1
pyobjc-framework-SearchKit 8.4.1
pyobjc-framework-Security 8.4.1
pyobjc-framework-SecurityFoundation 8.4.1
pyobjc-framework-SecurityInterface 8.4.1
pyobjc-framework-ServiceManagement 8.4.1
pyobjc-framework-ShazamKit 8.4.1
pyobjc-framework-Social 8.4.1
pyobjc-framework-SoundAnalysis 8.4.1
pyobjc-framework-Speech 8.4.1
pyobjc-framework-SpriteKit 8.4.1
pyobjc-framework-StoreKit 8.4.1
pyobjc-framework-SyncServices 8.4.1
pyobjc-framework-SystemConfiguration 8.4.1
pyobjc-framework-SystemExtensions 8.4.1
pyobjc-framework-UniformTypeIdentifiers 8.4.1
pyobjc-framework-UserNotifications 8.4.1
pyobjc-framework-UserNotificationsUI 8.4.1
pyobjc-framework-VideoSubscriberAccount 8.4.1
pyobjc-framework-VideoToolbox 8.4.1
pyobjc-framework-Virtualization 8.4.1
pyobjc-framework-Vision 8.4.1
pyobjc-framework-WebKit 8.4.1
pyparsing 3.0.9
pyttk 0.3.2
setuptools 62.3.2
six 1.16.0
sqlparse 0.4.2
toml 0.10.2
tomli 2.0.1
tox 3.25.1
virtualenv 20.15.1
wheel 0.37.1
zipp 3.8.0
% sw_vers
ProductName: macOS
ProductVersion: 12.3
BuildVersion: 21E230
% uname -m
arm64
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Thanks for the issue!
A note to self: the character used is U+3000 (ideographic space).
A workaround is to simply remove the space manually from your Markdown file. It should be redundant, not having any effect on rendered HTML anyways.
Thanks for fixing this!
Thanks for reporting this! Note that the fix remains unreleased for now. I'll probably release this together with https://github.com/executablebooks/mdformat/issues/336 as soon as that is ready.