Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a period in a directory name causes the rendered title to include only the left hand side of the directory #728

Closed
justinkinney opened this issue Sep 22, 2015 · 3 comments
Labels
Bug

Comments

@justinkinney
Copy link

@justinkinney justinkinney commented Sep 22, 2015

I noticed that using a period in a directory name causes the rendered title to lose everything to the right of the period.

cursor_and_seespn_docs

To replicate (assuming default docs directory path):

mkdir -p docs/Project\ with\ a.dot
echo "#testing" > docs/Project\ with\ a.dot/test\ page\ with\ a.dot.md
mkdocs build

I'm guessing the problem comes from filename_to_title(), but I don't have a suggestion for how to fix it at this point.

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Sep 22, 2015

Hmm, interesting. So Python see's this as all being part of the extension. That is annoying. I am not sure what a good fix would be.

@d0ugal d0ugal added the Bug label Sep 22, 2015
@waylan
Copy link
Member

@waylan waylan commented Sep 22, 2015

filename_to_title() calls os.path.splitext(filename)[0] on every name given to it. However, that should only be called on filenames, but not on directory names. Given filename_to_title() is only passed the base name (not the path) there is no way internally for the function to check whether it has a dir or file name (can't call os.path.isdir()). Therefore, that isdir test needs to happen in the calling code. Perhaps a second function dirname_to_title() could be created. Or require the ext to be removed prior to passing to filename_to_title().

@justinkinney
Copy link
Author

@justinkinney justinkinney commented Sep 22, 2015

A naive solution I played with was essentially adding the following to filename_to_title():

    for (dirpath, dirnames, filenames) in os.walk('docs'):
        for dirname in dirnames:
            if os.path.isdir('%s/%s' % (dirpath, dirname)):
                title = filename
            else:
                title = os.path.splitext(filename)[0]

it "works" but it's obviously pretty frail.

justinkinney pushed a commit to justinkinney/mkdocs that referenced this issue Sep 22, 2015
justinkinney pushed a commit to justinkinney/mkdocs that referenced this issue Sep 23, 2015
@d0ugal d0ugal closed this in dc7fee4 Mar 3, 2016
d0ugal added a commit that referenced this issue Mar 3, 2016
fixes #728
d0ugal added a commit that referenced this issue Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.