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

Printing the 'The Python Tutorial' #50919

Closed
brimac mannequin opened this issue Aug 8, 2009 · 9 comments
Closed

Printing the 'The Python Tutorial' #50919

brimac mannequin opened this issue Aug 8, 2009 · 9 comments
Assignees
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@brimac
Copy link
Mannequin

brimac mannequin commented Aug 8, 2009

BPO 6670
Nosy @birkenfeld, @ezio-melotti
Files
  • unnamed
  • unnamed
  • unnamed
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/birkenfeld'
    closed_at = <Date 2009-10-22.16:21:28.282>
    created_at = <Date 2009-08-08.19:50:04.939>
    labels = ['type-bug', 'docs']
    title = "Printing the 'The Python Tutorial'"
    updated_at = <Date 2009-10-23.08:24:47.183>
    user = 'https://bugs.python.org/brimac'

    bugs.python.org fields:

    activity = <Date 2009-10-23.08:24:47.183>
    actor = 'brimac'
    assignee = 'georg.brandl'
    closed = True
    closed_date = <Date 2009-10-22.16:21:28.282>
    closer = 'georg.brandl'
    components = ['Documentation']
    creation = <Date 2009-08-08.19:50:04.939>
    creator = 'brimac'
    dependencies = []
    files = ['15069', '15073', '15186']
    hgrepos = []
    issue_num = 6670
    keywords = []
    message_count = 9.0
    messages = ['91422', '91442', '93653', '93665', '93696', '93698', '93714', '94363', '94378']
    nosy_count = 4.0
    nosy_names = ['georg.brandl', 'jnoller', 'ezio.melotti', 'brimac']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6670'
    versions = ['Python 2.6']

    @brimac
    Copy link
    Mannequin Author

    brimac mannequin commented Aug 8, 2009

    I am having a problem when printing 'The Python Tutorial' at
    http://docs.python.org/tutorial/
    I am using XP and Firefox and an HP Laserjet.
    The page displays OK but the printout has a 68 mm margin on the left.
    The margin on the right is 18 mm but the text is cut off, sometimes
    mid-letter. The other 14 pages in the tutorial have the same problem.
    I've tried changing from Portrait to Landscape. The text gets wider, the
    margins are the same size, and the text is still cut off.
    I have not noticed this with any other documents, on this website or
    elsewhere. I'm sure if you print/preview you will see the problem.
    My guess is that there is a fault with the printout file at python.org

    @brimac brimac mannequin assigned birkenfeld Aug 8, 2009
    @brimac brimac mannequin added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels Aug 8, 2009
    @ezio-melotti
    Copy link
    Member

    I can reproduce the issue using the "Print preview" on Firefox and on
    IE, on the tutorial and on other pages as well.
    The Doc has a couple of print rules at the end of
    http://docs.python.org/_static/basic.css and they look correct (and they
    are also W3C valid). While I was trying to debug the problem using the
    Web Developer plug-in of Firefox and the "Edit CSS" option the problem
    disappeared without changing anything.
    This is quite weird and lead me to think that there could be a priority
    problem (even if I can't see any other rule that overrides the print rules).

    Possible solutions could be:

    1. add a couple of !important in the print rules;
    2. move the print rules somewhere else;
    3. create a distinct print CSS where to put all the print rules.

    @ezio-melotti
    Copy link
    Member

    To fix this problem is enough to add an !important to the margin: 0;
    rule in the @media print {} at the end of basic.css (line 408).

    I'll try to explain why the !important is necessary.
    In default.css @import url("basic.css"); (correctly) appears at the
    beginning, and imports the rules from basic.css, including the @media
    print {}. A few lines later, in default.css, there's the rule
    div.bodywrapper { margin: 0 0 0 230px; }, and with no @media specified
    it defaults on 'all'.

    In default.css we then end up with something equivalent to:

    /* This is defined in basic.css and imported
    at the beginning of default.css */
    @media print {
    /* some rules omitted for clarity */
    div.bodywrapper { margin: 0; }
    }

    /* This is defined later in default.css */
    @media all { /* This is implicit */
    div.bodywrapper { margin: 0 0 0 230px; }
    }

    When the file is printed both the rules are applied, because 'all' also
    includes 'print'.
    Since both the media have the same priority (i.e. the specific @media
    print does NOT have higher priority than the implicit @media all) and
    both the rules have the same priority too, the latter wins.
    The !important is then needed to raise the priority of the first rule.

    Note that adding the !important is not a really good solution IMHO: the
    problem could appear again if other rules with the same priority of the
    ones in @media print {} are specified elsewhere.
    A good solution would be to move the print rules after the normal ones,
    so in case the print media is used these rules will have higher priority.
    The @import can only appear at the beginning of a file so the two
    possible solutions are:

    1. put the rules with media all in, for example, all.css and the ones
      with media print in print.css and then, in default.css, write only:
      @import url('all.css');
      @import url('print.css') print;

    2. like 1) but importing the print.css separately using <link> in the
      html pages:
      <link href="default.css" type="text/css" rel="stylesheet">
      <link href="print.css" type="text/css" rel="stylesheet" media="print">

    A third solution might be to specify the media of the normal rules to
    'screen', but some rules are probably common to both the media.

    More information here: http://www.w3.org/TR/CSS2/cascade.html

    @jnoller
    Copy link
    Mannequin

    jnoller mannequin commented Oct 6, 2009

    I posted to the wrong bug, apologies

    @brimac
    Copy link
    Mannequin Author

    brimac mannequin commented Oct 7, 2009

    Hi Ezio

    Many thanks for all your effort with this problem.
    Thanks also for the full explanation and link.
    I'm not sure what happens now. Will somebody fix it?
    I think it's important for Python's image because
    it might be the first page a new user tries to print.

    brimac

    2009/10/6 Ezio Melotti <report@bugs.python.org>

    Ezio Melotti <ezio.melotti@gmail.com> added the comment:

    To fix this problem is enough to add an !important to the margin: 0;
    rule in the @media print {} at the end of basic.css (line 408).

    I'll try to explain why the !important is necessary.
    In default.css @import url("basic.css"); (correctly) appears at the
    beginning, and imports the rules from basic.css, including the @media
    print {}. A few lines later, in default.css, there's the rule
    div.bodywrapper { margin: 0 0 0 230px; }, and with no @media specified
    it defaults on 'all'.

    In default.css we then end up with something equivalent to:

    /* This is defined in basic.css and imported
    at the beginning of default.css */
    @media print {
    /* some rules omitted for clarity */
    div.bodywrapper { margin: 0; }
    }

    /* This is defined later in default.css */
    @media all { /* This is implicit */
    div.bodywrapper { margin: 0 0 0 230px; }
    }

    When the file is printed both the rules are applied, because 'all' also
    includes 'print'.
    Since both the media have the same priority (i.e. the specific @media
    print does NOT have higher priority than the implicit @media all) and
    both the rules have the same priority too, the latter wins.
    The !important is then needed to raise the priority of the first rule.

    Note that adding the !important is not a really good solution IMHO: the
    problem could appear again if other rules with the same priority of the
    ones in @media print {} are specified elsewhere.
    A good solution would be to move the print rules after the normal ones,
    so in case the print media is used these rules will have higher priority.
    The @import can only appear at the beginning of a file so the two
    possible solutions are:

    1. put the rules with media all in, for example, all.css and the ones
      with media print in print.css and then, in default.css, write only:
      @import url('all.css');
      @import url('print.css') print;

    2. like 1) but importing the print.css separately using <link> in the
      html pages:
      <link href="default.css" type="text/css" rel="stylesheet">
      <link href="print.css" type="text/css" rel="stylesheet" media="print">

    A third solution might be to specify the media of the normal rules to
    'screen', but some rules are probably common to both the media.

    More information here: http://www.w3.org/TR/CSS2/cascade.html

    ----------


    Python tracker <report@bugs.python.org>
    <http://bugs.python.org/issue6670\>


    @ezio-melotti
    Copy link
    Member

    I'm not sure what happens now. Will somebody fix it?

    Now that the problem and the solution are known, Georg will probably fix
    it at some point. The "!important" could be used as a temporary
    workaround (e.g. for 2.6.4 and for the online doc), the css can be
    reorganized later.

    @brimac
    Copy link
    Mannequin Author

    brimac mannequin commented Oct 7, 2009

    Hi Ezio

    Thanks again.

    Brimac

    2009/10/7 Ezio Melotti <report@bugs.python.org>

    Ezio Melotti <ezio.melotti@gmail.com> added the comment:

    > I'm not sure what happens now. Will somebody fix it?

    Now that the problem and the solution are known, Georg will probably fix
    it at some point. The "!important" could be used as a temporary
    workaround (e.g. for 2.6.4 and for the online doc), the css can be
    reorganized later.

    ----------


    Python tracker <report@bugs.python.org>
    <http://bugs.python.org/issue6670\>


    @birkenfeld
    Copy link
    Member

    OK, fixed in Sphinx, and in the Python stylesheet in r75617.

    @brimac
    Copy link
    Mannequin Author

    brimac mannequin commented Oct 23, 2009

    Georg, Ezio
    Many Thanks
    brimac

    2009/10/22 Georg Brandl <report@bugs.python.org>

    Georg Brandl <georg@python.org> added the comment:

    OK, fixed in Sphinx, and in the Python stylesheet in r75617.

    ----------
    resolution: -> fixed
    status: open -> closed


    Python tracker <report@bugs.python.org>
    <http://bugs.python.org/issue6670\>


    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants